1 var maps = []; 2 var mainMap; 3 var activeMarker = null; 4 var activeMarkers = []; 5 var infowindow; 6 7 /* 8 * new_map 9 * 10 * This function will render a Google Map onto the selected jQuery element 11 * 12 * @type function 13 * @date 8/11/2013 14 * @since 4.3.0 15 * 16 * @param $el (jQuery element) 17 * @return n/a 18 */ 19 function new_map( $el, $isModal = false ) { 20 activeMarkers = []; 21 var args = { 22 zoom : 16, 23 center : new google.maps.LatLng(0,0), 24 mapTypeId : google.maps.MapTypeId.ROADMAP, 25 disableDefaultUI: true, 26 styles: [{"elementType":"geometry","stylers":[{"color":"#f5f5f5"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#f5f5f5"}]},{"featureType":"administrative.country","elementType":"geometry.stroke","stylers":[{"color":"#7d7d7d"},{"visibility":"on"},{"weight":1}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#bdbdbd"}]},{"featureType":"administrative.province","elementType":"geometry.stroke","stylers":[{"color":"#7d7d7d"},{"visibility":"on"},{"weight":1}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#eeeeee"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#e5e5e5"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#ffffff"}]},{"featureType":"road.arterial","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#dadada"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"color":"#e5e5e5"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#eeeeee"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#c9c9c9"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]}] 27 }; 28 29 // create map 30 var map = new google.maps.Map( $el[0], args); 31 32 // add a markers reference 33 map.markers = []; 34 35 var markerLocations = $el.parents('.map-wrapper').find('.map-data'); 36 add_map_markers(map, markerLocations, $isModal); 37 38 google.maps.event.trigger(map, 'resize'); 39 40 // return 41 return map; 42 } 43 44 $(document).on('click', '.map-wrapper .result', function () { 45 $('.map-wrapper .result').removeClass('active'); 46 $(this).addClass('active'); 47 const markerIndex = $(this).data('count'); 48 const marker = mainMap.markers[markerIndex]; 49 50 if (marker) { 51 google.maps.event.trigger(marker, 'click'); 52 } 53 }); 54 55 /* 56 * add_marker 57 * 58 * This function will add a marker to the selected Google Map 59 * 60 * @type function 61 * @date 8/11/2013 62 * @since 4.3.0 63 * 64 * @param $marker (jQuery element) 65 * @param map (Google Map object) 66 * @return n/a 67 */ 68 function add_marker( $marker, map ) { 69 //var vlat = parseFloat($marker.attr('data-latt')); 70 var lngg = parseFloat($marker.data('lngg')); 71 var latt = parseFloat($marker.data('latt')); 72 var icon_color = $marker.data('icon-color'); 73 var latlng = new google.maps.LatLng( latt, lngg );//$marker.attr('data-lng') $marker.attr('data-lat') 74 75 let markerSVG = ''; 76 77 if (icon_color === 'red') { 78 markerSVG = ` 79 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1370 2056.82" width="35" height="53"> 80 <path fill="#e31c37" d="m683.8,0C302.54.66-3.49,310.22.03,691.47c.02,2.7.07,5.4.12,8.09,2.32,111.18,33.44,219.86,88.71,316.36l596.14,1040.9,595.92-1040.51c56.39-98.46,87.69-209.56,89.03-323.02.03-2.76.05-5.52.05-8.29C1370,306.28,1062.67-.65,683.8,0Z"/> 81 <polygon fill="#ffffff" points="787 1116.15 1081.61 406.06 866.48 406.06 571.88 1116.15 787 1116.15"/> 82 <polygon fill="#ffffff" points="668.74 835.72 496.39 406.06 288.39 406.06 563.08 1090.81 668.74 835.72"/> 83 </svg> 84 `; 85 } else { 86 markerSVG = ` 87 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1370 2056.82" width="35" height="53"> 88 <path fill="#404040" d="m683.8,0C302.54.66-3.49,310.22.03,691.47c.02,2.7.07,5.4.12,8.09,2.32,111.18,33.44,219.86,88.71,316.36l596.14,1040.9,595.92-1040.51c56.39-98.46,87.69-209.56,89.03-323.02.03-2.76.05-5.52.05-8.29C1370,306.28,1062.67-.65,683.8,0Z"/> 89 <polygon fill="#ffffff" points="787 1116.15 1081.61 406.06 866.48 406.06 571.88 1116.15 787 1116.15"/> 90 <polygon fill="#ffffff" points="668.74 835.72 496.39 406.06 288.39 406.06 563.08 1090.81 668.74 835.72"/> 91 </svg> 92 `; 93 } 94 95 const defaultIcon = { 96 url: 'data:image/svg+xml,' + encodeURIComponent(markerSVG), 97 scaledSize: new google.maps.Size(36, 55), 98 }; 99 100 var myLatLng = {lat: latt, lng: lngg}; 101 var marker = new google.maps.Marker({ 102 position: myLatLng, 103 map: map, 104 icon: defaultIcon, 105 }); 106 activeMarkers.push(marker); 107 map.markers.push( marker ); 108 109 // if marker contains HTML, add it to an infoWindow 110 if( $marker.html() ){ 111 112 // show info window when marker is clicked 113 google.maps.event.addListener(marker, 'click', function() { 114 if (marker === activeMarker) { 115 return; 116 } 117 var index = map.markers.indexOf( marker ); 118 $('.map-wrapper .result').removeClass('active'); 119 $('.map-wrapper .result[data-count="' + index + '"]').addClass('active'); 120 var activeResult = $('.map-wrapper .result.active'); 121 var resultsWrapper = $('.search-results-wrapper'); 122 if(resultsWrapper.length > 0){ 123 resultsWrapper.scrollTop(activeResult.position().top - resultsWrapper.position().top + resultsWrapper.scrollTop()); 124 } 125 126 infowindow.setOptions({pixelOffset: new google.maps.Size(-20,-30)}); 127 infowindow.setContent($marker.html()); 128 infowindow.setPosition(marker.getPosition()); 129 infowindow.open( map, marker ); 130 131 marker.setIcon({ 132 url: marker.getIcon().url, 133 scaledSize: new google.maps.Size(50, 75), 134 }); 135 136 marker.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 137 138 if (activeMarker) { 139 activeMarker.setIcon({ 140 url: activeMarker.getIcon().url, 141 scaledSize: new google.maps.Size(36, 55), 142 }); 143 144 activeMarker.setZIndex(google.maps.Marker.MAX_ZINDEX); 145 } 146 147 activeMarker = marker; 148 }); 149 150 // * 151 // START INFOWINDOW CUSTOMIZE. 152 // The google.maps.event.addListener() event expects 153 // the creation of the infowindow HTML structure 'domready' 154 // and before the opening of the infowindow, defined styles are applied. 155 // http://en.marnoto.com/2014/09/5-formas-de-personalizar-infowindow.html 156 // * 157 google.maps.event.addListener(infowindow, 'domready', function() { 158 // Reference to the DIV that wraps the bottom of infowindow 159 var iwOuter = $('.gm-style-iw-d'); 160 iwOuter.css({'overflow': 'hidden', 'overflow-x': 'scroll'}) 161 /* Since this div is in a position prior to .gm-div style-iw.
162 * We use jQuery and create a iwBackground variable, 163 * and took advantage of the existing reference .gm-style-iw for the previous div with .prev(). 164 */ 165 var iwBackground = iwOuter.parent(); 166 iwBackground.css({'padding-top' : '0'}); 167 168 // Reference to the div that groups the close button elements. 169 var iwCloseBtn = iwOuter.next(); 170 171 // Apply the desired effect to the close button 172 iwCloseBtn.css({display: 'none'}); 173 174 google.maps.event.addListener(map, "click", function(event) { 175 infowindow.close(); 176 177 if (activeMarker) { 178 activeMarker.setIcon({ 179 url: activeMarker.getIcon().url, 180 scaledSize: new google.maps.Size(35, 48), 181 }); 182 183 activeMarker.setZIndex(google.maps.Marker.MAX_ZINDEX); 184 185 activeMarker = null; 186 } 187 }); 188 }); 189 } 190 } 191 192 /* 193 * center_map 194 * 195 * This function will center the map, showing all markers attached to this map 196 * 197 * @type function 198 * @date 8/11/2013 199 * @since 4.3.0 200 * 201 * @param map (Google Map object) 202 * @return n/a 203 */ 204 function center_map( map, markerLocations ) { 205 //console.log(map); 206 // vars 207 var bounds = new google.maps.LatLngBounds(); 208 209 // loop through all markers and create bounds 210 $.each( map.markers, function( i, marker ){ 211 var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() ); 212 bounds.extend( latlng ); 213 }); 214 215 // only 1 marker?
216 if( markerLocations.length == 1 ){ 217 //console.log(' = 1'); 218 // set center of map 219 map.setCenter( bounds.getCenter() ); 220 map.setZoom( 14 ); 221 }else if(markerLocations.length == 0){//when no address is set, center on UT 222 //console.log(' = 0') 223 map.setCenter( new google.maps.LatLng(40, -111) ); 224 map.setZoom( 4 ); 225 }else{ 226 // console.log(' > 1'); 227 map.fitBounds( bounds ); 228 } 229 } 230 231 //Add Map Markers 232 function add_map_markers(map, markerLocations, $isModal){ 233 //remove old markers 234 if(map.markers.length > 1){ 235 for (let i = 0; i < map.markers.length; i++) { 236 map.markers[i].setMap(null); 237 } 238 map.markers = []; 239 } 240 241 // add markers 242 for(var i = 0; i < markerLocations.length; i++){ 243 add_marker($(markerLocations[i]), map); 244 } 245 246 if($isModal){ 247 center_map(map, markerLocations); 248 } 249 250 google.maps.event.trigger(map, 'resize'); 251 } 252 var autocomplete; 253 window.initMap = function(){ 254 // Make sure the 'google' variable is defined 255 if (typeof google === 'undefined') { 256 return; 257 } 258 259 //Initialize Autocomplete, on join and insurance page 260 if(window.location.href.includes('/insurance')){ 261 window.initAutocomplete(); 262 } 263 264 infowindow = new google.maps.InfoWindow(); 265 266 $('.modal-map.load').each(function(){ 267 // // create map 268 map = new_map( $(this), true ); 269 maps.push(map); 270 $(this).removeClass('load'); 271 }); 272 273 for(var i = 0; i < maps.length; i++){ 274 google.maps.event.addListenerOnce(maps[i], 'idle', function(){ 275 document.getElementsByTagName('iframe')[0].title = "Google Map for VASA Locations"; 276 }); 277 } 278 279 } 280 281 // On location page, add api on load(don't wait for an click event to happen) 282 if( $("#GM-API-Loaded").length === 0 ){ 283 addGoogleAPI(); 284 } 285 286 function addGoogleAPI(){ 287 var tag = document.createElement('script'); 288 var siteProtocol = ( location.protocol != 'https:' ) ? 'http' : 'https'; 289 tag.src = siteProtocol + "://maps.googleapis.com/maps/api/js?key="+key+"&language="+(typeof mapLang !== 'undefined' ? mapLang : 'en')+"&loading=async&callback=initMap"; 290 291 if(window.location.href.includes('/insurance')){ // Only insurance uses the legacy Places and geometry libraries. 292 tag.src += "&libraries=geometry,places"; 293 } 294 var firstScriptTag = document.getElementsByTagName('script')[0]; 295 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 296 tag.id = "GM-API-Loaded"; 297 } 298 299 300 /*************************************** 301 * kp 03/28/24 - New version of location search, should replace ajaxLocationSearch eventually 302 * *************************************/ 303 $(document).ready(function() { 304 305 // Location-search interactions are registered by global/location-search. 306 $(document).on("click", ".map-toggle", function (e) { 307 e.preventDefault(); 308 309 if($('.map-wrapper').hasClass('list-view')) { //currently on list view, switch to map view 310 if ($('.main-map.load').length > 0) { 311 initMap(); 312 } else { 313 // var markerLocations = $('.locations-page-map .map-data'); 314 // center_map(mainMap, markerLocations); 315 } 316 317 $('.map-wrapper').removeClass('list-view').addClass('map-view'); 318 319 } else{ //currently on map view, switch to list view 320 $('.map-wrapper').addClass('list-view').removeClass('map-view'); 321 } 322 323 }); 324 325 // If on location page, set up event listener to load .main-map if resized past medium 326 if($('.page-template-locations').length > 0){ 327 $(window).on('changed.zf.mediaquery', function(event, newSize, oldSize){ 328 if(newSize == 'medium'){ 329 if( $(".main-map.load").length > 0 ){ 330 initMap(); 331 } 332 } 333 }); 334 335 // on breakbpoint change of any size re-center the map 336 $(window).on('changed.zf.mediaquery', function(event, newSize, oldSize){ 337 if(mainMap != null){ 338 var markerLocations = $('.locations-page-map .map-data'); 339 center_map(mainMap, markerLocations); 340 } 341 }); 342 } 343 344 // $(document).on("mouseenter", ".result", function (e) { 345 // var count = $(this).data('count'); 346 // console.log(mainMap.markers[count]); 347 // // mainMap.markers[count].setIcon(gicons.yellow) 348 // }); 349 });
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.