1var map; 2var markers = []; 3 4//Initialization for the map 5function ptGMinit () { 6 7 //Get map center 8 var container = jQuery('.pt-map'); 9 var center = { 10 lat: container.data("lat"), 11 lng: container.data("lng") 12 } 13 14 //Set marker Icon 15 var icon = { 16 url: window.location.href + 'wp-content/themes/parkerTruTech/assets/img/map-marker.png' 17 } 18 19 //Set Responsive Zoom 20 var zoom = 5; 21 22 //Initialize Map 23 map = new google.maps.Map(document.getElementById('map'), { 24 center: {lat: center.lat, lng: center.lng}, 25 zoom: zoom, 26 scrollwheel: false, 27 streetViewControl: false, 28 mapTypeControl: false, 29 styles: [ 30 { 31 "featureType": "road", 32 "elementType": "all", 33 "stylers": [ 34 { "visibility": "off" } 35 ] 36 } 37 ] 38 }); 39 40 //Close all Location cards on zoom 41 map.addListener('zoom_changed', function() { 42 close_all_cards(); 43 }); 44 45 map.addListener('dragstart', function() { 46 close_all_cards(); 47 }) 48 49 map.addListener('bounds_changed', function() { 50 close_all_cards(); 51 }) 52 53 var mapBounds = new google.maps.LatLngBounds(); 54 55 //Array to store locations and markers 56 jQuery('.pt-map .pt-location').each(function(index){ 57 if(!(jQuery(this).data("lat") && jQuery(this).data("lat"))) { 58 return; 59 } 60 61 //set marker location 62 var location = { 63 lat: jQuery(this).data("lat"), 64 lng: jQuery(this).data("lng") 65 } 66 67 //Create new marker 68 var marker = new google.maps.Marker({ 69 position: {lat: location.lat, lng: location.lng}, 70 map: map, 71 icon: icon 72 }); 73 74 mapBounds.extend(marker.position); 75 76 //Add event listener for marker clicks 77 marker.addListener('click', function(e) { 78 show_location_card(index); 79 80 this.setIcon(window.location.href + 'wp-content/themes/parkerTruTech/assets/img/map-marker-outline.png'); 81 82 }); 83 84 markers.push(marker); 85 }); 86 87 map.fitBounds(mapBounds); 88 89 jQuery('.pt-location-close').click(close_all_cards); 90 91 //Shows a specific location card 92 function show_location_card (i) { 93 var location = jQuery('.pt-location-' + i); 94 95 var locationW = location.outerWidth(); 96 var locationH = location.outerHeight(); 97 98 //Close all cards 99 close_all_cards(); 100 101 if(window.innerWidth <= 767) { 102 103 var mX = 'calc(50% - ' + (locationW/2) + 'px)'; 104 console.log(mX); 105 var mY = '15px'; 106 107 //Chanegs css properties to display card 108 location.css({"opacity":"1", "top": "auto", "bottom": mY, "left": mX, "z-index": 1}); 109 110 111 } else { 112 //The X coordinate of the location box 113 var mX = (event.offsetX < locationW) ? event.offsetX + 'px' : (event.offsetX - locationW) + 'px'; 114 115 //The Y coordinate of the location box 116 //If space to the top of the map is not large enough for the card, then show below 117 var mY = (event.offsetY < locationH) ? event.offsetY + 'px' : (event.offsetY - locationH) + 'px'; 118 119 //Chanegs css properties to display card 120 location.css({"opacity":"1", "top": mY, "left": mX, "z-index": 1}); 121 } 122 } 123 124 //Closes all location cards 125 function close_all_cards() { 126 jQuery('.pt-location').css({"opacity":"0", "z-index": -1}); 127 128 markers.forEach(function(marker) { 129 marker.setIcon(window.location.href + 'wp-content/themes/parkerTruTech/assets/img/map-marker.png'); 130 }); 131 } 132}
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.