1function acfmap() { 2 /* 3 * new_map 4 * 5 * This function will render a Google Map onto the selected jQuery element 6 * 7 * @type function 8 * @date 8/11/2013 9 * @since 4.3.0 10 * 11 * @param $el (jQuery element) 12 * @return n/a 13 */ 14 15 function new_map($el) { 16 // var 17 var $markers = $el.find(".marker"); 18 19 // vars 20 var args = { 21 zoom: 17, 22 center: new google.maps.LatLng(0, 0), 23 mapTypeId: google.maps.MapTypeId.ROADMAP, 24 /*styles: [ 25 { elementType: "geometry", stylers: [{ color: "#f5f5f5" }] }, 26 { elementType: "labels.icon", stylers: [{ visibility: "off" }] }, 27 { elementType: "labels.text.fill", stylers: [{ color: "#616161" }] }, 28 { elementType: "labels.text.stroke", stylers: [{ color: "#f5f5f5" }] }, 29 { 30 featureType: "administrative.land_parcel", 31 elementType: "labels.text.fill", 32 stylers: [{ color: "#bdbdbd" }], 33 }, 34 { 35 featureType: "poi", 36 elementType: "geometry", 37 stylers: [{ color: "#eeeeee" }], 38 }, 39 { 40 featureType: "poi", 41 elementType: "labels.text.fill", 42 stylers: [{ color: "#757575" }], 43 }, 44 { 45 featureType: "poi.park", 46 elementType: "geometry", 47 stylers: [{ color: "#e5e5e5" }], 48 }, 49 { 50 featureType: "poi.park", 51 elementType: "labels.text.fill", 52 stylers: [{ color: "#9e9e9e" }], 53 }, 54 { 55 featureType: "road", 56 elementType: "geometry", 57 stylers: [{ color: "#ffffff" }], 58 }, 59 { 60 featureType: "road.arterial", 61 elementType: "labels.text.fill", 62 stylers: [{ color: "#757575" }], 63 }, 64 { 65 featureType: "road.highway", 66 elementType: "geometry", 67 stylers: [{ color: "#dadada" }], 68 }, 69 { 70 featureType: "road.highway", 71 elementType: "labels.text.fill", 72 stylers: [{ color: "#616161" }], 73 }, 74 { 75 featureType: "road.local", 76 elementType: "labels.text.fill", 77 stylers: [{ color: "#9e9e9e" }], 78 }, 79 { 80 featureType: "transit.line", 81 elementType: "geometry", 82 stylers: [{ color: "#e5e5e5" }], 83 }, 84 { 85 featureType: "transit.station", 86 elementType: "geometry", 87 stylers: [{ color: "#eeeeee" }], 88 }, 89 { 90 featureType: "water", 91 elementType: "geometry", 92 stylers: [{ color: "#c9c9c9" }], 93 }, 94 { 95 featureType: "water", 96 elementType: "labels.text.fill", 97 stylers: [{ color: "#9e9e9e" }], 98 }, 99 ],*/ 100 }; 101 102 // create map 103 var map = new google.maps.Map($el[0], args); 104 105 // add a markers reference 106 map.markers = []; 107 108 // add markers 109 $markers.each(function () { 110 add_marker(jQuery(this), map); 111 }); 112 113 // center map 114 center_map(map); 115 116 // return 117 return map; 118 } 119 120 /* 121 * add_marker 122 * 123 * This function will add a marker to the selected Google Map 124 * 125 * @type function 126 * @date 8/11/2013 127 * @since 4.3.0 128 * 129 * @param $marker (jQuery element) 130 * @param map (Google Map object) 131 * @return n/a 132 */ 133 134 function add_marker($marker, map) { 135 // var 136 var latlng = new google.maps.LatLng( 137 $marker.attr("data-lat"), 138 $marker.attr("data-lng") 139 ); 140 141 // create marker 142 var marker = new google.maps.Marker({ 143 position: latlng, 144 map: map, 145 icon: { 146 url: "/wp-content/themes/swarco/images/map-marker.svg" // URL of the black marker icon 147 } 148 }); 149 150 151 // add to array 152 map.markers.push(marker); 153 154 // if marker contains HTML, add it to an infoWindow 155 if ($marker.html()) { 156 // create info window 157 var infowindow = new google.maps.InfoWindow({ 158 content: $marker.html(), 159 }); 160 161 // show info window when marker is clicked 162 google.maps.event.addListener(marker, "click", function () { 163 infowindow.open(map, marker); 164 }); 165 } 166 } 167 168 /* 169 * center_map 170 * 171 * This function will center the map, showing all markers attached to this map 172 * 173 * @type function 174 * @date 8/11/2013 175 * @since 4.3.0 176 * 177 * @param map (Google Map object) 178 * @return n/a 179 */ 180 181 function center_map(map) { 182 // vars 183 var bounds = new google.maps.LatLngBounds(); 184 185 // loop through all markers and create bounds 186 jQuery.each(map.markers, function (i, marker) { 187 var latlng = new google.maps.LatLng( 188 marker.position.lat(), 189 marker.position.lng() 190 ); 191 192 bounds.extend(latlng); 193 }); 194 195 // only 1 marker? 196 if (map.markers.length == 1) { 197 // set center of map 198 map.setCenter(bounds.getCenter()); 199 map.setZoom(17); 200 } else {
201 // fit to bounds 202 map.fitBounds(bounds); 203 } 204 } 205 206 /* 207 * document ready 208 * 209 * This function will render each map when the document is ready (page has loaded) 210 * 211 * @type function 212 * @date 8/11/2013 213 * @since 5.0.0 214 * 215 * @param n/a 216 * @return n/a 217 */ 218 // global var 219 var map = null; 220 221 jQuery(document).ready(function ($) { 222 jQuery(".acf-map").each(function () { 223 // create map 224 map = new_map(jQuery(this)); 225 }); 226 }); 227}
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.