1(function($) { 2var geocoder; 3function new_map( $el ) { 4 5 // var 6 var $markers = $('.localisation'); 7 8 // vars 9 var args = { 10 zoom : 6, 11 center : new google.maps.LatLng(0, 0), 12 scrollwheel: false, 13 panControl: false, 14 zoomControl: true, 15 mapTypeControl: false, 16 streetViewControl: true, 17 mapTypeId : google.maps.MapTypeId.ROADMAP, 18 zoomControlOptions: { 19 position: google.maps.ControlPosition.RIGHT_BOTTOM 20 }, 21 }; 22 23 24 // create map 25 var map = new google.maps.Map( $el[0], args); 26 27 map.set('styles', [ { "stylers": [ { "lightness": 51 } ] },{ "featureType": "road", "elementType": "labels", "stylers": [ { "visibility": "off" } ] },{ "featureType": "poi", "stylers": [ { "visibility": "off" } ] },{ "featureType": "transit", "stylers": [ { "visibility": "off" } ] },{ "featureType": "road.highway", "stylers": [ { "color": "#FDC230" }, { "lightness": 64 } ] },{ "featureType": "water", "elementType": "geometry", "stylers": [ { "color": "#C4E4E0" }, { "lightness": 11 } ] },{ "featureType": "water", "elementType": "labels", "stylers": [ { "visibility": "off" } ] },{ "featureType": "administrative.country", "elementType": "labels", "stylers": [ { "visibility": "off" } ]}] ); 28 29 30 // add a markers reference 31 map.markers = []; 32 33 // add markers 34 $markers.each(function(){ 35 add_marker( $(this), map ); 36 }); 37 38 // center map 39 center_map( map ); 40 41 // return 42 return map; 43} 44 45var tab_markers = []; 46var openedInfoWindow = null; 47function add_marker( $marker, map ) { 48 49 if($marker.attr('data-lat')=='vide'){ 50 51 }else{ 52 53 // var 54 var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') ); 55 56 //draw a map 57 var image = { 58 // Adresse de l'icône personnalisée 59 //url: jQuery(".acf-map").data('marker'), 60 //url: 'http://www.legout.xyz/wp-content/themes/sdg/img/picto_enseignants.png', 61 url: $marker.attr('data-marker'), 62 // Taille de l'icône personnalisée 63 size: new google.maps.Size(55, 55), 64 scaledSize: new google.maps.Size(55, 55), 65 66 // Origine de l'image, souvent (0, 0) 67 origin: new google.maps.Point(0,0), 68 // L'ancre de l'image. Correspond au point de l'image que l'on raccroche à la carte. Par exemple, si votre îcone est un drapeau, cela correspond à son mâts 69 //anchor: new google.maps.Point(20, 30) 70 }; 71 // create marker 72 var marker = new google.maps.Marker({ 73 position : latlng, 74 map : map, 75 url : $marker.attr('data-url'), 76 icon: image 77 }); 78 79 // add to array 80 map.markers.push( marker ); 81 //tab_markers[$marker.attr('data-mid')] = marker; 82 83 /*google.maps.event.addListener(marker, 'click', function() { 84 window.location.href = this.url; 85 });*/ 86 87 // if marker contains HTML, add it to an infoWindow 88 if( $marker.html() ) 89 { 90 // create info window 91 var activeWindow; 92 var infowindow = new google.maps.InfoWindow({ 93 content : $marker.html() 94 }); 95 96 // show info window when marker is clicked 97 google.maps.event.addListener(marker, 'click', function() { 98 if (openedInfoWindow != null) 99 openedInfoWindow.close(); 100 infowindow.open(map,marker); 101 openedInfoWindow = infowindow; 102 google.maps.event.addListener(infowindow, 'closeclick', function() { 103 openedInfoWindow = null; 104 }); 105 google.maps.event.addListener(map, 'click', function() { 106 infowindow.close(); 107 }) ; 108 }); 109 /*google.maps.event.addListener(marker, 'mouseover', function() { 110 111 marker.setIcon(jQuery(".acf-map").data('over')); 112 }); 113 google.maps.event.addListener(marker, 'mouseout', function() { 114 115 marker.setIcon(jQuery(".acf-map").data('marker')); 116 });*/ 117 } 118 119 }//else vide 120} 121 122function center_map( map ) { 123/* 124 // vars 125 var bounds = new google.maps.LatLngBounds(); 126 127 // loop through all markers and create bounds 128 $.each( map.markers, function( i, marker ){ 129 var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() ); 130 bounds.extend( latlng ); 131 }); 132 */ 133 var options = { 134 imagePath: $("#le_prog").data('cluster')+'/m', 135 maxZoom: 10 136 }; 137 138 var markerCluster = new MarkerClusterer(map, map.markers, options); 139 140 var latlng = new google.maps.LatLng( 47,2.2775175 ); 141 map.setCenter( latlng ); 142 map.setZoom( 6 ); 143 144} 145 146 function codeAddress(point) { 147 var lat = point.data('lat'); 148 if(lat!=''){ 149 add_marker( point, map ); 150 }else{ 151 /* Récupération de la valeur de l'adresse saisie */ 152 var address = point.html(); 153 /* Appel au service de geocodage avec l'adresse en paramètre */ 154 geocoder.geocode( { 'address': address}, function(results, status) { 155 /* Si l'adresse a pu être géolocalisée */ 156 if (status == google.maps.GeocoderStatus.OK) { 157 /* Récupération de sa latitude et de sa longitude */ 158 point.data('lat',results[0].geometry.location.lat()); 159 point.data('lng',results[0].geometry.location.lng()); 160 161 add_marker( point, map ); 162 /* 163 map.setCenter(results[0].geometry.location); 164 / * Affichage du marker * / 165 var marker = new google.maps.Marker({ 166 map: map, 167 position: results[0].geometry.location 168 }); 169 / * Permet de supprimer le marker précédemment affiché * / 170 markers.push(marker); 171 if(markers.length > 1) 172 markers[(i-1)].setMap(null); 173 i++; 174 */ 175 } else { 176 console.log("Le geocodage n\'a pu etre effectue pour la raison suivante: " + status); 177 } 178 }); 179 } 180 } 181 function getL(response) { 182 var resp = response.split('#'); 183 var type = resp[0]; 184 var ida = resp[1]; 185 var address = resp[2]; 186 187 geocoder.geocode( { 'address': address}, function(results, status) { 188 /* Si l'adresse a pu être géolocalisée */ 189 if (status == google.maps.GeocoderStatus.OK) { 190 /* Récupération de sa latitude et de sa longitude */ 191 var tabL = results[0].geometry.location.lat()+','+results[0].geometry.location.lng(); 192 193 //ajax 194 jQuery.post( 195 ajaxurl, 196 { 197 'action': 'up_geo', 198 'type':type, 199 'id':ida, 200 'value':tabL 201 }, 202 function(response){ 203 if(response!==''){ 204 setTimeout(get_geo,1750); 205 } 206 }); 207 } else { 208 //ajax 209 jQuery.post( 210 ajaxurl, 211 { 212 'action': 'up_geo', 213 'type':type, 214 'id':ida, 215 'value':'vide,vide' 216 }, 217 function(response){ 218 if(response!==''){ 219 setTimeout(get_geo,1750); 220 } 221 }); 222 console.log(address+"Le geocodage n\'a pu etre effectue pour la raison suivante: " + status); 223 } 224 }); 225 } 226 227 228 229 function get_geo(){ 230 //ajax 231 jQuery.post( 232 ajaxurl, 233 { 234 'action': 'new_geo', 235 }, 236 function(response){ 237 if(response!==''){ 238 getL(response); 239 240 } 241 }); 242 } 243// 244// global var
245var map = null; 246$(document).ready(function(){ 247 if($(".acf-map").length){ 248 249 $('.acf-map').hide(); 250 // create map 251 setTimeout(function(){ 252 map = new_map( $('.acf-map') ); 253 $('.acf-map').show(); 254 },500); 255 geocoder = new google.maps.Geocoder(); 256 257 258 /*$(".localisation").each(function(){ 259 add_marker($(this), map); 260 });*/ 261 262 } 263 264 get_geo(); 265 if($(".localisation").length<1){ 266 $('#nb_result').html('Aucun résultat pour votre recherche'); 267 }else{ 268 $('#nb_result').html($(".localisation").length+' activitée(s) trouvée(s)'); 269 } 270 271 $("#change_view").change(function(){ 272 $(this).closest('form').submit(); 273 }); 274}); 275 276 277})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.