1var WPGM_Path_Polygon = new Array(); 2var WPGM_Path = new Array(); 3var infoWindow_poly = Array(); 4var marker_array = Array(); 5var marker_sl = null; 6 7for (var entry in wpgmaps_localize) { 8 if ('undefined' === typeof window.jQuery) { 9 setTimeout(function(){ document.getElementById('wpgmza_map').innerHTML = 'Error: In order for WP Google Maps to work, jQuery must be installed. A check was done and jQuery was not present. Please see the <a href="http://www.wpgmaps.com/documentation/troubleshooting/jquery-troubleshooting/" title="WP Google Maps - jQuery Troubleshooting">jQuery troubleshooting section of our site</a> for more information.'; }, 5000); 10 } 11} 12 13function wpgmza_parse_theme_data(raw) 14{ 15 16 var json; 17 18 try{ 19 json = JSON.parse(raw); 20 }catch(e) { 21 try{ 22 json = eval(raw); 23 }catch(e) { 24 console.warn("Couldn't parse theme data"); 25 return []; 26 } 27 } 28 29 return json; 30} 31 32function wpgmza_get_guid() 33{ 34 function s4() { 35 return Math.floor((1 + Math.random()) * 0x10000) 36 .toString(16) 37 .substring(1); 38 } 39 return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); 40} 41 42function wpgmza_open_info_window(infoWindow, content) 43{ 44 var guid = wpgmza_get_guid(); 45 var div = $("<div hidden data-info-window-guid='" + guid + "'/>"); 46 47 infoWindow.setContent(div); 48 infoWindow.open(); 49 50 $("div[data-info-window-guid='" + guid + "']").trigger("infowindowopen.wpgmza"); 51} 52 53function InitMap() { 54 55 var $ = jQuery; 56 57 if(WPGMZA.googleAPIStatus && WPGMZA.googleAPIStatus.code == "USER_CONSENT_NOT_GIVEN") 58 { 59 $("#wpgmza_map, .wpgmza_map").each(function(index, el) { 60 $(el).append($(WPGMZA.api_consent_html)); 61 $(el).css({height: "auto"}); 62 }); 63 64 $("button.wpgmza-api-consent").on("click", function(event) { 65 Cookies.set("wpgmza-api-consent-given", true); 66 window.location.reload(); 67 }); 68 69 return; 70 } 71 72 var myLatLng = { 73 lat: wpgmaps_localize[wpgmaps_mapid].map_start_lat, 74 lng: wpgmaps_localize[wpgmaps_mapid].map_start_lng 75 }; 76 77 if(typeof wpgmza_override_zoom !== "undefined") 78 MYMAP.init('#wpgmza_map', myLatLng, parseInt(wpgmza_override_zoom)); 79 else 80 MYMAP.init('#wpgmza_map', myLatLng, parseInt(wpgmaps_localize[wpgmaps_mapid].map_start_zoom)); 81 82 UniqueCode=Math.round(Math.random()*10000); 83 84 MYMAP.placeMarkers(wpgmaps_markerurl+'?u='+UniqueCode,wpgmaps_localize[wpgmaps_mapid].id,null,null,null); 85 86 if(wpgmaps_localize[wpgmaps_mapid].other_settings.store_locator_style == 'modern') 87 { 88 MYMAP.modernStoreLocator = WPGMZA.ModernStoreLocator.createInstance(wpgmaps_mapid); 89 wpgmza_create_places_autocomplete(); 90 } 91} 92jQuery(function() { 93 94 jQuery(document).ready(function(){ 95 if (/1\.([0-7])\.([0-9])/.test(jQuery.fn.jquery)) { 96 setTimeout(function(){ 97 document.getElementById('wpgmza_map').innerHTML = 'Error: Your version of jQuery is outdated. WP Google Maps requires jQuery version 1.7+ to function correctly. Go to Maps->Settings and check the box that allows you to over-ride your current jQuery to try eliminate this problem.'; 98 }, 6000); 99 } else { 100 101 // Fastclick adapation 102 jQuery(document).on({'DOMNodeInserted': function() { 103 jQuery('.pac-item, .pac-item span', this).addClass('needsclick'); 104 } 105 }, '.pac-container'); 106 107 var temp; 108 var selector = "#wpgmza_map"; 109 var mapElement = jQuery(selector); 110 111 var width = wpgmaps_localize[wpgmaps_mapid]['map_width']+wpgmaps_localize[wpgmaps_mapid]['map_width_type']; 112 var height = wpgmaps_localize[wpgmaps_mapid]['map_height']+wpgmaps_localize[wpgmaps_mapid]['map_height_type']; 113 114 if((temp = mapElement.attr("data-shortcode-width")) != "inherit") 115 width = temp; 116 if((temp = mapElement.attr("data-shortcode-height")) != "inherit") 117 height = temp; 118 119 mapElement.css({ 120 width: width, 121 height: height 122 }); 123 124 InitMap(); 125 jQuery('body').on('tabsactivate', function(){setTimeout(function(){InitMap();}, 500); }); 126 jQuery('body').on('tabsshow', function(){setTimeout(function(){InitMap();}, 500); }); 127 jQuery('body').on('accordionactivate', function(){setTimeout(function(){InitMap();}, 500); }); 128 jQuery('body').on('click', '.wpb_tabs_nav li', function(){setTimeout(function(){InitMap();}, 500); }); 129 jQuery('body').on('click', '.ui-tabs-nav li', function(event, ui) { InitMap(); }); 130 jQuery('body').on('click', '.tp-tabs li a', function(event, ui) { InitMap(); }); 131 jQuery('body').on('click', '.nav-tabs li a', function(event, ui) { InitMap(); }); 132 jQuery('body').on('click', '.vc_tta-panel-heading', function(){setTimeout(function(){InitMap();}, 500); }); 133 jQuery('body').on('click', '.ult_exp_section',function(){setTimeout(function(){InitMap();}, 500); }); 134 jQuery('body').on('click', '.x-accordion-heading', function(){setTimeout(function(){InitMap();}, 500); }); 135 jQuery('body').on('click', '.x-nav-tabs li', function(){setTimeout(function(){InitMap();}, 500); }); 136 jQuery('body').on('click', '.tab-title', function(){setTimeout(function(){InitMap();}, 500); }); 137 jQuery('body').on('click', '.tab-link', function(){setTimeout(function(){InitMap();}, 500); }); 138 jQuery('body').on('click', '.et_pb_tabs_controls li', function(){setTimeout(function(){InitMap();}, 500); }); 139 jQuery('body').on('click', '.fusion-tab-heading', function(){setTimeout(function(){InitMap();}, 500); }); 140 jQuery('body').on('click', '.et_pb_tab', function(){setTimeout(function(){InitMap();}, 500); }); 141 jQuery('body').on('click', '.tri-tabs-nav span', function(){setTimeout(function(){InitMap();}, 500); }); 142 jQuery('body').on('click', '.gdl-tabs li', function(){setTimeout(function(){InitMap();}, 500); }); 143 jQuery('body').on('click', '#tabnav li', function(){setTimeout(function(){InitMap();}, 500); }); 144 } 145 });
146}); 147 148var MYMAP = { 149 map: null, 150 bounds: null 151} 152 153if (wpgmaps_localize_global_settings['wpgmza_settings_map_draggable'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_draggable']) { wpgmza_settings_map_draggable = true; } else { wpgmza_settings_map_draggable = false; } 154if (wpgmaps_localize_global_settings['wpgmza_settings_map_clickzoom'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_clickzoom']) { wpgmza_settings_map_clickzoom = false; } else { wpgmza_settings_map_clickzoom = true; } 155if (wpgmaps_localize_global_settings['wpgmza_settings_map_scroll'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_scroll']) { wpgmza_settings_map_scroll = true; } else { wpgmza_settings_map_scroll = false; } 156if (wpgmaps_localize_global_settings['wpgmza_settings_map_zoom'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_zoom']) { wpgmza_settings_map_zoom = true; } else { wpgmza_settings_map_zoom = false; } 157if (wpgmaps_localize_global_settings['wpgmza_settings_map_pan'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_pan']) { wpgmza_settings_map_pan = true; } else { wpgmza_settings_map_pan = false; } 158if (wpgmaps_localize_global_settings['wpgmza_settings_map_type'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_type']) { wpgmza_settings_map_type = true; } else { wpgmza_settings_map_type = false; } 159if (wpgmaps_localize_global_settings['wpgmza_settings_map_streetview'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_streetview']) { wpgmza_settings_map_streetview = true; } else { wpgmza_settings_map_streetview = false; } 160if (wpgmaps_localize_global_settings['wpgmza_settings_map_full_screen_control'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_map_full_screen_control']) { wpgmza_settings_map_full_screen_control = true; } else { wpgmza_settings_map_full_screen_control = false; } 161 162if ('undefined' === typeof wpgmaps_localize[wpgmaps_mapid]['other_settings']['map_max_zoom'] || wpgmaps_localize[wpgmaps_mapid]['other_settings']['map_max_zoom'] === "") { wpgmza_max_zoom = 0; } else { wpgmza_max_zoom = parseInt(wpgmaps_localize[wpgmaps_mapid]['other_settings']['map_max_zoom']); } 163if ('undefined' === typeof wpgmaps_localize[wpgmaps_mapid]['other_settings']['map_min_zoom'] || wpgmaps_localize[wpgmaps_mapid]['other_settings']['map_min_zoom'] === "") { wpgmza_min_zoom = 21; } else { wpgmza_min_zoom = parseInt(wpgmaps_localize[wpgmaps_mapid]['other_settings']['map_min_zoom']); } 164 165function wpgmza_create_places_autocomplete() { 166 167 var element = document.getElementById("addressInput"); 168 169 if(!element) 170 return; 171 172 if(!window.google) 173 return; 174 175 if(!google.maps) 176 return; 177 178 if(!google.maps.places || !google.maps.places.Autocomplete) 179 return; 180 181 var options = { 182 types: ["geocode"] 183 }; 184 185 var restriction = wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_store_locator_restrict']; 186 187 if(restriction) 188 options.componentRestrictions.country = restriction; 189 190 autocomplete = new google.maps.places.Autocomplete(element, options); 191 google.maps.event.addListener(autocomplete, 'place_changed', function() { 192 fillInAddress(); 193 }); 194} 195 196MYMAP.init = function(selector, latLng, zoom) { 197 198 var maptype = null; 199 200 if(window.google) 201 { 202 if (typeof wpgmaps_localize[wpgmaps_mapid].type !== "undefined") { 203 if (wpgmaps_localize[wpgmaps_mapid].type === "1") { maptype = google.maps.MapTypeId.ROADMAP; } 204 else if (wpgmaps_localize[wpgmaps_mapid].type === "2") { maptype = google.maps.MapTypeId.SATELLITE; } 205 else if (wpgmaps_localize[wpgmaps_mapid].type === "3") { maptype = google.maps.MapTypeId.HYBRID; } 206 else if (wpgmaps_localize[wpgmaps_mapid].type === "4") { maptype = google.maps.MapTypeId.TERRAIN; } 207 else { maptype = google.maps.MapTypeId.ROADMAP; } 208 } else { 209 maptype = google.maps.MapTypeId.ROADMAP; 210 } 211 } 212 213 var myOptions = { 214 zoom:zoom, 215 minZoom: wpgmza_max_zoom,
216 maxZoom: wpgmza_min_zoom, 217 center: latLng, 218 zoomControl: wpgmza_settings_map_zoom, 219 panControl: wpgmza_settings_map_pan, 220 mapTypeControl: wpgmza_settings_map_type, 221 streetViewControl: wpgmza_settings_map_streetview, 222 draggable: wpgmza_settings_map_draggable, 223 disableDoubleClickZoom: wpgmza_settings_map_clickzoom, 224 scrollwheel: wpgmza_settings_map_scroll, 225 fullscreenControl: wpgmza_settings_map_full_screen_control, 226 mapTypeId: maptype 227 } 228 229 if(typeof wpgmza_force_greedy_gestures !== "undefined"){ 230 myOptions.gestureHandling = wpgmza_force_greedy_gestures; 231 } 232 233 // NB: Perry: Moved this block up here and altered it so it plays nicely with other maps styles settings 234 if ("undefined" !== typeof wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_theme_data'] && wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_theme_data'] !== false && wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_theme_data'] !== "") { 235 if(!myOptions.styles) 236 myOptions.styles = []; 237 238 wpgmza_theme_data = wpgmza_parse_theme_data(wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_theme_data']); 239 myOptions.styles = myOptions.styles.concat(wpgmza_theme_data); 240 } 241 242 if(!wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_show_points_of_interest']) 243 { 244 // Only create a new array if styles aren't set already, so no existing styles are overwritten 245 if(!myOptions.styles) 246 myOptions.styles = []; 247 248 // Push a style to hide all points of interest 249 myOptions.styles.push( 250 { 251 featureType: "poi", 252 stylers: [{visibility: "off"}] 253 } 254 ); 255 } 256 257 var element = jQuery(selector)[0]; 258 259 element.setAttribute("data-map-id", 1); 260 element.setAttribute("data-maps-engine", WPGMZA.settings.engine); 261 this.map = WPGMZA.Map.createInstance(element, myOptions); 262 this.bounds = new WPGMZA.LatLngBounds(); 263 264 if(MYMAP.modernStoreLocator) 265 { 266 MYMAP.modernStoreLocator.element.index = 1; 267 this.map.controls[google.maps.ControlPosition.TOP_CENTER].push(MYMAP.modernStoreLocator.element); 268 wpgmza_create_places_autocomplete(); 269 } 270 271 /*var map = this.map; 272 google.maps.event.addDomListener(window, "resize", function() { 273 var center = map.getCenter(); 274 google.maps.event.trigger(map, "resize"); 275 map.setCenter(center); 276 });*/ 277 278 jQuery( "#wpgmza_map").trigger( 'wpgooglemaps_loaded' ); 279 280 if (wpgmaps_localize_polygon_settings !== null) { 281 if (typeof wpgmaps_localize_polygon_settings !== "undefined") { 282 for(var poly_entry in wpgmaps_localize_polygon_settings) { 283 add_polygon(poly_entry); 284 } 285 } 286 } 287 if (wpgmaps_localize_polyline_settings !== null) { 288 if (typeof wpgmaps_localize_polyline_settings !== "undefined") { 289 for(var poly_entry in wpgmaps_localize_polyline_settings) { 290 add_polyline(poly_entry); 291 } 292 } 293 } 294 295 if(WPGMZA.settings.engine == "google-maps") 296 { 297 if (wpgmaps_localize[wpgmaps_mapid]['bicycle'] === "1") { 298 var bikeLayer = new google.maps.BicyclingLayer(); 299 bikeLayer.setMap(MYMAP.map.googleMap); 300 } 301 if (wpgmaps_localize[wpgmaps_mapid]['traffic'] === "1") { 302 var trafficLayer = new google.maps.TrafficLayer(); 303 trafficLayer.setMap(MYMAP.map.googleMap); 304 } 305 306 if ("undefined" !== typeof wpgmaps_localize[wpgmaps_mapid]['other_settings']['transport_layer'] && wpgmaps_localize[wpgmaps_mapid]['other_settings']['transport_layer'] === 1) { 307 var transitLayer = new google.maps.TransitLayer(); 308 transitLayer.setMap(MYMAP.map.googleMap); 309 } 310 } 311 312 if(window.wpgmza_circle_data_array) { 313 window.circle_array = []; 314 315 for(var circle_id in wpgmza_circle_data_array) { 316 317 // Check that this belongs to the array itself, as opposed to its prototype, or else this will break if you add methods to the array prototype (please don't extend the native types) 318 if(!wpgmza_circle_data_array.hasOwnProperty(circle_id)) 319 continue; 320 321 add_circle(1, wpgmza_circle_data_array[circle_id]); 322 } 323 } 324 325 if(window.wpgmza_rectangle_data_array) { 326 window.rectangle_array = []; 327 328 for(var rectangle_id in wpgmza_rectangle_data_array) { 329 330 // Check that this belongs to the array itself, as opposed to its prototype, or else this will break if you add methods to the array prototype (please don't extend the native types) 331 if(!wpgmza_rectangle_data_array.hasOwnProperty(rectangle_id)) 332 continue; 333 334 add_rectangle(1, wpgmza_rectangle_data_array[rectangle_id]); 335 336 } 337 } 338 339 MYMAP.map.on("click", function(event) { 340 if(event.target instanceof WPGMZA.Marker) 341 return; 342 343 infoWindow.close(); 344 });
345 346 window.addEventListener("keydown", function(e) { 347 var k = (e.which ? e.which : e.keyCode); 348 if(k == 27) 349 infoWindow.close(); 350 }); 351} 352 353//var infoWindow = new google.maps.InfoWindow(); 354var infoWindow; 355jQuery(document).ready(function() { 356 infoWindow = WPGMZA.InfoWindow.createInstance(); 357 if (typeof wpgmaps_localize_global_settings['wpgmza_settings_infowindow_width'] !== "undefined" && wpgmaps_localize_global_settings['wpgmza_settings_infowindow_width'] !== "") { infoWindow.setOptions({maxWidth:wpgmaps_localize_global_settings['wpgmza_settings_infowindow_width']}); } 358}); 359 360/*google.maps.event.addDomListener(window, 'resize', function() { 361 var myLatLng = new google.maps.LatLng(wpgmaps_localize[wpgmaps_mapid].map_start_lat,wpgmaps_localize[wpgmaps_mapid].map_start_lng); 362 MYMAP.map.setCenter(myLatLng); 363});*/ 364 365if(!window.WPGMZA) 366 window.WPGMZA = {}; 367 368WPGMZA.KM_PER_MILE = 1.60934; 369WPGMZA.MILE_PER_KM = 0.621371; 370 371WPGMZA.UNITS_MILES = 1; 372WPGMZA.UNITS_KM = 2; 373 374function wpgmza_get_zoom_from_radius(radius, units) 375{ 376 // With thanks to Jeff Jason http://jeffjason.com/2011/12/google-maps-radius-to-zoom/ 377 378 if(units == WPGMZA.UNITS_MILES) 379 radius *= WPGMZA.KM_PER_MILE; 380 381 return Math.round(14-Math.log(radius)/Math.LN2); 382} 383 384var wpgmza_last_default_circle = null; 385 386function wpgmza_show_store_locator_radius(map_id, center, radius, distance_type) 387{ 388 switch(wpgmaps_localize[map_id].other_settings.wpgmza_store_locator_radius_style) 389 { 390 case "modern": 391 if(MYMAP.modernStoreLocatorCircle) 392 MYMAP.modernStoreLocatorCircle.destroy(); 393 394 MYMAP.modernStoreLocatorCircle = WPGMZA.ModernStoreLocatorCircle.createInstance(map_id); 395 396 MYMAP.modernStoreLocatorCircle.setOptions({ 397 visible: true, 398 center: center, 399 radius: radius * (distance_type == 1 ? WPGMZA.KM_PER_MILE : 1), 400 radiusString: radius 401 }); 402 403 break; 404 405 default: 406 var options = { 407 strokeColor: '#FF0000', 408 strokeOpacity: 0.25, 409 strokeWeight: 2,
410 fillColor: '#FF0000', 411 fillOpacity: 0.15, 412 map: MYMAP.map, 413 center: center 414 }; 415 416 if (distance_type == "1") 417 options.radius = parseInt(radius / 0.000621371); 418 else 419 options.radius = parseInt(radius / 0.001); 420 421 if(typeof wpgmza_last_default_circle !== "undefined" && wpgmza_last_default_circle !== null){ 422 wpgmza_last_default_circle.setMap(null); 423 wpgmza_last_default_circle = null; 424 } 425 426 wpgmza_last_default_circle = WPGMZA.Circle.createInstance(options); 427 break; 428 } 429} 430 431MYMAP.placeMarkers = function(filename,map_id,radius,searched_center,distance_type) { 432 var check1 = 0, 433 slNotFoundMessage = jQuery('.js-not-found-msg'); 434 if (wpgmaps_localize_global_settings.wpgmza_settings_marker_pull === '1') { 435 jQuery.get(filename, function(xml){ 436 jQuery(xml).find("marker").each(function(){ 437 var wpmgza_map_id = jQuery(this).find('map_id').text(); 438 439 if (wpmgza_map_id == map_id) { 440 var wpmgza_address = jQuery(this).find('address').text(); 441 var lat = jQuery(this).find('lat').text(); 442 var lng = jQuery(this).find('lng').text(); 443 var wpmgza_anim = jQuery(this).find('anim').text(); 444 var wpmgza_infoopen = jQuery(this).find('infoopen').text(); 445 var current_lat = jQuery(this).find('lat').text(); 446 var current_lng = jQuery(this).find('lng').text(); 447 var show_marker_radius = true; 448 var wpmgza_marker_id = jQuery(this).find('marker_id').text(); 449 450 if (radius !== null) { 451 if (check1 > 0 ) { } else { 452 453 454 var point = new WPGMZA.LatLng(parseFloat(searched_center.lat),parseFloat(searched_center.lng)); 455 MYMAP.bounds.extend(point); 456 if (typeof wpgmaps_localize[wpgmaps_mapid]['other_settings']['store_locator_bounce'] === "undefined" || wpgmaps_localize[wpgmaps_mapid]['other_settings']['store_locator_bounce'] === 1) { 457 var marker = WPGMZA.Marker.createInstance({ 458 position: point, 459 map: MYMAP.map, 460 animation: WPGMZA.Marker.ANIMATION_BOUNCE 461 }) 462 463 marker_sl = marker; 464 } 465 466 wpgmza_show_store_locator_radius(map_id, point, radius, distance_type); 467 468 check1 = check1 + 1; 469 } 470 var R = 0; 471 if (distance_type == "1") { 472 R = 3958.7558657440545; 473 } else { 474 R = 6378.16; 475 } 476 var dLat = toRad(searched_center.lat-current_lat); 477 var dLon = toRad(searched_center.lng-current_lng); 478 var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(toRad(current_lat)) * Math.cos(toRad(searched_center.lat)) * Math.sin(dLon/2) * Math.sin(dLon/2); 479 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 480 var d = R * c; 481 482 if (d < radius) { show_marker_radius = true; } else { show_marker_radius = false; } 483 } 484 485 var point = new WPGMZA.LatLng(parseFloat(lat),parseFloat(lng)); 486 487 MYMAP.bounds.extend(point); 488 489 if (show_marker_radius === true) { 490 491 var options = { 492 position: point, 493 map: MYMAP.map 494 } 495 496 if(wpmgza_anim) 497 options.animation = wpmgza_anim; 498 499 var marker = WPGMZA.Marker.createInstance(options); 500 501 var d_string = ""; 502 if (radius !== null) { 503 if (distance_type == "1") { 504 d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+" "+wpgmaps_lang_m_away+"</p>"; 505 } else { 506 d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+" "+wpgmaps_lang_km_away+"</p>"; 507 } 508 } else { d_string = ''; } 509 510 511 var html='<span style=\'min-width:100px; display:block;\'>'+wpmgza_address+'</span>'+d_string; 512 if (wpmgza_infoopen === "1" && !wpgmaps_localize_global_settings["wpgmza_settings_disable_infowindows"]) { 513 infoWindow.setContent(html); 514 infoWindow.open(MYMAP.map, marker); 515 } 516 temp_actiontype = 'click'; 517 if (typeof wpgmaps_localize_global_settings.wpgmza_settings_map_open_marker_by !== "undefined" && wpgmaps_localize_global_settings.wpgmza_settings_map_open_marker_by == '2') { 518 temp_actiontype = 'mouseover'; 519 } 520 521 marker.on(temp_actiontype, function() { 522 infoWindow.close(); 523 if(!wpgmaps_localize_global_settings["wpgmza_settings_disable_infowindows"]) 524 { 525 infoWindow.setContent(html); 526 infoWindow.open(MYMAP.map, marker); 527 } 528 }); 529 530 marker_array[wpmgza_marker_id] = marker; 531 } 532 } 533 }); 534 535 }); 536 } else { 537 538 if (Object.keys(wpgmaps_localize_marker_data).length > 0) { 539 var markerStoreLocatorsNum = 0; 540 541 if (typeof wpgmaps_localize_marker_data !== "undefined") { 542 543 jQuery.each(wpgmaps_localize_marker_data, function(i, val) { 544 545 var wpmgza_map_id = val.map_id; 546 547 if (wpmgza_map_id == map_id) { 548 549 var wpmgza_address = val.address; 550 var wpmgza_anim = val.anim; 551 var wpmgza_infoopen = val.infoopen; 552 var lat = val.lat; 553 var lng = val.lng; 554 var point = new WPGMZA.LatLng(lat, lng); 555 var wpmgza_marker_id = val.marker_id; 556 557 558 var current_lat = val.lat; 559 var current_lng = val.lng; 560 var show_marker_radius = true; 561 562 if (radius !== null) { 563 if (check1 > 0 ) { } else { 564 565 566 var point = searched_center; 567 MYMAP.bounds.extend(point); 568 if (typeof wpgmaps_localize[wpgmaps_mapid]['other_settings']['store_locator_bounce'] === "undefined" || wpgmaps_localize[wpgmaps_mapid]['other_settings']['store_locator_bounce'] === 1) { 569 var marker = WPGMZA.Marker.createInstance({ 570 position: point, 571 map: MYMAP.map/*, 572 animation: google.maps.Animation.BOUNCE*/ 573 }); 574 marker_sl = marker; 575 } else { /* dont show icon */ } 576 577 wpgmza_show_store_locator_radius(map_id, point, radius, distance_type); 578 579 check1 = check1 + 1; 580 } 581 var R = 0; 582 if (distance_type == "1") { 583 R = 3958.7558657440545; 584 } else { 585 R = 6378.16; 586 } 587 var dLat = toRad(searched_center.lat-current_lat); 588 var dLon = toRad(searched_center.lng-current_lng); 589 var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.
589cos(toRad(current_lat)) * Math.cos(toRad(searched_center.lat)) * Math.sin(dLon/2) * Math.sin(dLon/2); 590 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 591 var d = R * c; 592 593 if (d < radius) { 594 show_marker_radius = true; 595 markerStoreLocatorsNum++; 596 } else { 597 show_marker_radius = false; 598 } 599 } 600 601 var point = { 602 lat: parseFloat(lat), 603 lng: parseFloat(lng) 604 }; 605 606 MYMAP.bounds.extend(point); 607 608 if (show_marker_radius === true) { 609 610 var marker = WPGMZA.Marker.createInstance({ 611 position: point, 612 map: MYMAP.map 613 }); 614 615 if(wpmgza_anim) 616 marker.setAnimation(wpmgza_anim); 617 618 var d_string = ""; 619 if (radius !== null) { 620 if (distance_type == "1") { 621 d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+" "+wpgmaps_lang_m_away+"</p>"; 622 } else { 623 d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+" "+wpgmaps_lang_km_away+"</p>"; 624 } 625 } else { d_string = ''; } 626 627 628 var html='<span style=\'min-width:100px; display:block;\'>'+wpmgza_address+'</span>'+d_string; 629 if (wpmgza_infoopen === "1" && !wpgmaps_localize_global_settings["wpgmza_settings_disable_infowindows"]) { 630 infoWindow.setContent(html); 631 infoWindow.open(MYMAP.map, marker); 632 } 633 temp_actiontype = 'click'; 634 if (typeof wpgmaps_localize_global_settings.wpgmza_settings_map_open_marker_by !== "undefined" && wpgmaps_localize_global_settings.wpgmza_settings_map_open_marker_by == '2') { 635 temp_actiontype = 'mouseover'; 636 } 637 //google.maps.event.addListener(marker, temp_actiontype, function() { 638 marker.on(temp_actiontype, function() { 639 infoWindow.close(); 640 if(!wpgmaps_localize_global_settings["wpgmza_settings_disable_infowindows"]) 641 { 642 infoWindow.setContent(html); 643 infoWindow.open(MYMAP.map, marker); 644 } 645 }); 646 647 marker_array[wpmgza_marker_id] = marker; 648 } 649 } 650 }); 651 652 if ('' !== jQuery('#addressInput').val() && markerStoreLocatorsNum < 1) { 653 slNotFoundMessage.addClass('is-active'); 654 setTimeout(function () { 655 slNotFoundMessage.removeClass('is-active'); 656 }, 5000); 657 } 658 } 659 } 660 } 661} 662 663function add_polygon(polygonid) { 664 665 if(WPGMZA.settings.engine != "google-maps") 666 return; 667 668 var tmp_data = wpgmaps_localize_polygon_settings[polygonid]; 669 var current_poly_id = polygonid; 670 var tmp_polydata = tmp_data['polydata']; 671 var WPGM_PathData = new Array(); 672 for (tmp_entry2 in tmp_polydata) { 673 if (typeof tmp_polydata[tmp_entry2][0] !== "undefined") { 674 675 WPGM_PathData.push(new google.maps.LatLng(tmp_polydata[tmp_entry2][0], tmp_polydata[tmp_entry2][1])); 676 } 677 } 678 if (tmp_data['lineopacity'] === null || tmp_data['lineopacity'] === "") { 679 tmp_data['lineopacity'] = 1; 680 } 681 682 var bounds = new google.maps.LatLngBounds(); 683 for (i = 0; i < WPGM_PathData.length; i++) { 684 bounds.extend(WPGM_PathData[i]); 685 } 686 687 WPGM_Path_Polygon[polygonid] = new google.maps.Polygon({ 688 path: WPGM_PathData, 689 clickable: true, /* must add option for this */ 690 strokeColor: "#"+tmp_data['linecolor'], 691 fillOpacity: tmp_data['opacity'], 692 strokeOpacity: tmp_data['lineopacity'], 693 fillColor: "#"+tmp_data['fillcolor'], 694 strokeWeight: 2, 695 map: MYMAP.map.googleMap 696 }); 697 WPGM_Path_Polygon[polygonid].setMap(MYMAP.map.googleMap); 698 699 polygon_center = bounds.getCenter(); 700 701 if (tmp_data['title'] !== "") { 702 infoWindow_poly[polygonid] = new google.maps.InfoWindow(); 703 google.maps.event.addListener(WPGM_Path_Polygon[polygonid], 'click', function(event) { 704 infoWindow_poly[polygonid].setPosition(event.latLng); 705 content = ""; 706 if (tmp_data['link'] !== "") { 707 var content = "<a href='"+tmp_data['link']+"'>"+tmp_data['title']+"</a>"; 708 } else { 709 var content = tmp_data['title']; 710 } 711 if(!wpgmaps_localize_global_settings["wpgmza_settings_disable_infowindows"]) 712 { 713 infoWindow_poly[polygonid].setContent(content); 714 infoWindow_poly[polygonid].open(MYMAP.map,this.position); 715 } 716 }); 717 } 718 719 720 721} 722function add_polyline(polyline) { 723 724 if(WPGMZA.settings.engine != "google-maps") 725 return; 726 727 var tmp_data = wpgmaps_localize_polyline_settings[polyline]; 728 729 var current_poly_id = polyline; 730 var tmp_polydata = tmp_data['polydata']; 731 var WPGM_Polyline_PathData = new Array(); 732 for (tmp_entry2 in tmp_polydata) { 733 if (typeof tmp_polydata[tmp_entry2][0] !== "undefined" && typeof tmp_polydata[tmp_entry2][1] !== "undefined") { 734 var lat = tmp_polydata[tmp_entry2][0].replace(')', ''); 735 lat = lat.replace('(',''); 736 var lng = tmp_polydata[tmp_entry2][1].replace(')', ''); 737 lng = lng.replace('(',''); 738 WPGM_Polyline_PathData.push(new google.maps.LatLng(lat, lng)); 739 } 740 741 742 } 743 if (tmp_data['lineopacity'] === null || tmp_data['lineopacity'] === "") { 744 tmp_data['lineopacity'] = 1; 745 } 746 747 WPGM_Path[polyline] = new google.maps.Polyline({ 748 path: WPGM_Polyline_PathData, 749 strokeColor: "#"+tmp_data['linecolor'], 750 strokeOpacity: tmp_data['opacity'], 751 strokeWeight: tmp_data['linethickness'], 752 map: MYMAP.map.googleMap 753 }); 754 WPGM_Path[polyline].setMap(MYMAP.map.googleMap); 755 756 757} 758 759 760jQuery("body").on("keypress","#addressInput", function(event) { 761 if ( event.which == 13 ) { 762 jQuery('.wpgmza_sl_search_button').trigger('click'); 763 } 764}); 765var autocomplete; 766function fillInAddress() { 767 // Get the place details from the autocomplete object. 768 var place = autocomplete.getPlace(); 769} 770 771wpgmza_create_places_autocomplete(); 772 773 774function searchLocations(map_id) { 775 var address = document.getElementById("addressInput").value; 776 777 if(address.length == 0) 778 { 779 document.getElementById("addressInput").focus(); 780 return; 781 } 782 783 //var geocoder = new google.maps.Geocoder(); 784 var geocoder = WPGMZA.Geocoder.createInstance(); 785 786 var options = { 787 address: address 788 }; 789 790 var restrict = wpgmaps_localize[wpgmaps_mapid]['other_settings']['wpgmza_store_locator_restrict']; 791 if(restrict && restrict.length) 792 options.componentRestrictions = restrict; 793 794 geocoder.geocode(options, function(results, status) { 795 796 if(status == WPGMZA.Geocoder.SUCCESS) 797 searchLocationsNear(map_id,results[0].geometry.location); 798 else 799 alert(address + ' not found'); 800 801 }); 802} 803function clearLocations() { 804 infoWindow.close(); 805} 806function searchLocationsNear(mapid,center_searched) { 807 clearLocations(); 808 var distance_type = wpgmaps_localize[mapid].other_settings.store_locator_distance; 809 810 var radius = document.getElementById('radiusSelect').value; 811 var zoomie = wpgmza_get_zoom_from_radius(radius); 812 813 MYMAP.map.setCenter(center_searched); 814 MYMAP.map.setZoom(zoomie); 815 if (typeof marker_array !== "undefined") { 816 jQuery.each(marker_array,function(i,v){ 817 /* remove any instance of a marker first tio avoid using a full reinit which causes the map to flicker */ 818 if (typeof v !== 'undefined') { 819 820 v.setMap(null); 821 /* Check which map we are working on, and only reset the correct markers. (Store locator, etc) */ 822 } 823 }); 824 } 825 if (marker_sl !== null){ 826 marker_sl.setMap(null); 827 } 828 MYMAP.placeMarkers(wpgmaps_markerurl+'?u='+UniqueCode,wpgmaps_localize[wpgmaps_mapid].id,radius,center_searched,distance_type); 829} 830 831function toRad(Value) { 832 /** Converts numeric degrees to radians */ 833 return Value * Math.PI / 180; 834} 835 836(function($) { 837 838 if(!window.WPGMZA) 839 window.WPGMZA = {}; 840 841 WPGMZA.hexToRgba = function(hex) { 842 var c; 843 if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){ 844 c= hex.substring(1).split(''); 845 if(c.length== 3){ 846 c= [c[0], c[0], c[1], c[1], c[2], c[2]]; 847 } 848 c= '0x'+c.join(''); 849 850 return { 851 r: (c>>16)&255, 852 g: (c>>8)&255, 853 b: c&255, 854 a: 1 855 }; 856 } 857 throw new Error('Bad Hex'); 858 } 859 860 WPGMZA.rgbaToString = function(rgba) { 861 return "rgba(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ", " + rgba.a + ")"; 862 } 863 864 WPGMZA.GoogleAPIErrorHandler = function() { 865 866 if(WPGMZA.settings.engine != "google-maps") 867 return; 868 869 var _error = console.error; 870 871 console.error = function(message) 872 { 873 var m = message.match(/^Google Maps API error: (\w+) (.+)/); 874 875 if(m) 876 { 877 var friendlyMessage = m[1].replace(/([A-Z])/g, " $1") + " - See " + m[2] + " for more information"; 878 alert(friendlyMessage); 879 } 880 881 _error.apply(this, arguments); 882 } 883 } 884 885 WPGMZA.googleAPIErrorHandler = new WPGMZA.GoogleAPIErrorHandler(); 886 887})(jQuery); 888 889function add_circle(mapid, data) 890{ 891 if(WPGMZA.settings.engine != "google-maps") 892 return; 893 894 data.map = MYMAP.map.googleMap; 895 896 if(!(data.center instanceof google.maps.LatLng)) { 897 898 if(typeof data.center != "string") 899 return; 900 901 var m = data.center.match(/-?\d+(\.\d*)?/g); 902 data.center = new google.maps.LatLng({ 903 lat: parseFloat(m[0]), 904 lng: parseFloat(m[1]), 905 }); 906 } 907 908 data.radius = parseFloat(data.radius); 909 data.fillColor = data.color;
910 data.fillOpacity = parseFloat(data.opacity); 911 912 data.strokeOpacity = 0; 913 914 var circle = new google.maps.Circle(data); 915 circle_array.push(circle); 916} 917 918function add_rectangle(mapid, data) 919{ 920 if(WPGMZA.settings.engine != "google-maps") 921 return; 922 923 data.map = MYMAP.map.googleMap; 924 925 data.fillColor = data.color; 926 data.fillOpacity = parseFloat(data.opacity); 927 928 var northWest = data.cornerA; 929 var southEast = data.cornerB; 930 931 var m = northWest.match(/-?\d+(\.\d+)?/g); 932 var north = parseFloat(m[0]); 933 var west = parseFloat(m[1]); 934 935 m = southEast.match(/-?\d+(\.\d+)?/g); 936 var south = parseFloat(m[0]); 937 var east = parseFloat(m[1]); 938 939 data.bounds = { 940 north: north, 941 west: west, 942 south: south, 943 east: east 944 }; 945 946 data.strokeOpacity = 0; 947 948 var rectangle = new google.maps.Rectangle(data); 949 rectangle_array.push(rectangle); 950}
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.