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