PageSourceSearch

https://veitchlister.com/wp-content/themes/vlc-march-2020/js/map.js

js veitchlister.com collected 2026-10-04 13:25:18 UTC 4,160 bytes, 171 lines download raw bytes

1(function($) {
2
3/*
4*  new_map
5*
6*  This function will render a Google Map onto the selected jQuery element
7*
8*  @type	function
9*  @date	8/11/2013
10*  @since	4.3.0
11*
12*  @param	$el (jQuery element)
13*  @return	n/a
14*/
15
16function new_map( $el ) {
17
18 // var
19 var $markers = $el.find('.marker');
20
21
22 // vars
23 var args = {
24   zoom		: 16,
25   center		: new google.maps.LatLng(0, 0),
26   mapTypeId	: google.maps.MapTypeId.ROADMAP,
27   styles: [{"featureType":"all","elementType":"labels.text.fill","stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}]},{"featureType":"all","elementType":"labels.text.stroke","stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}]},{"featureType":"all","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"administrative","elementType":"geometry.fill","stylers":[{"color":"#fefefe"},{"lightness":20}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}]},{"featureType":"landscape","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":20}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#f5f5f5"},{"lightness":21}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#dedede"},{"lightness":21}]},{"featureType":"road.highway","elementType":"geometry.fill","stylers":[{"color":"#ffffff"},{"lightness":17}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":18}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#ffffff"},{"lightness":16}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#f2f2f2"},{"lightness":19}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#e9e9e9"},{"lightness":17}]}]
28
29 };
30
31
32 // create map
33 var map = new google.maps.Map( $el[0], args);
34
35
36 // add a markers reference
37 map.markers = [];
38
39
40 // add markers
41 $markers.each(function(){
42
43     add_marker( $(this), map );
44
45 });
46
47
48 // center map
49 center_map( map );
50
51
52 // return
53 return map;
54
55}
56
57/*
58*  add_marker
59*
60*  This function will add a marker to the selected Google Map
61*
62*  @type	function
63*  @date	8/11/2013
64*  @since	4.3.0
65*
66*  @param	$marker (jQuery element)
67*  @param	map (Google Map object)
68*  @return	n/a
69*/
70
71function add_marker( $marker, map ) {
72
73 // var
74 var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
75
76 // create marker
77 var marker = new google.maps.Marker({
78   position	: latlng,
79   map			: map
80 });
81
82 // add to array
83 map.markers.push( marker );
84
85 // if marker contains HTML, add it to an infoWindow
86 if( $marker.html() )
87 {
88   // create info window
89   var infowindow = new google.maps.InfoWindow({
90     content		: $marker.html()
91   });
92
93   // show info window when marker is clicked
94   google.maps.event.addListener(marker, 'click', function() {
95
96     infowindow.open( map, marker );
97
98   });
99 }
100
101}
102
103/*
104*  center_map
105*
106*  This function will center the map, showing all markers attached to this map
107*
108*  @type	function
109*  @date	8/11/2013
110*  @since	4.3.0
111*
112*  @param	map (Google Map object)
113*  @return	n/a
114*/
115
116function center_map( map ) {
117
118 // vars
119 var bounds = new google.maps.LatLngBounds();
120
121 // loop through all markers and create bounds
122 $.each( map.markers, function( i, marker ){
123
124   var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
125
126   bounds.extend( latlng );
127
128 });
129
130 // only 1 marker?
131 if( map.markers.length == 1 )
132 {
133   // set center of map
134     map.setCenter( bounds.getCenter() );
135     map.setZoom( 16 );
136 }
137 else
138 {
139   // fit to bounds
140   map.fitBounds( bounds );
141 }
142
143}
144
145/*
146*  document ready
147*
148*  This function will render each map when the document is ready (page has loaded)
149*
150*  @type	function
151*  @date	8/11/2013
152*  @since	5.0.0
153*
154*  @param	n/a
155*  @return	n/a
156*/
157// global var
158var map = null;
159
160$(document).ready(function(){
161
162 $('.acf-map').each(function(){
163
164   // create map
165   map = new_map( $(this) );
166
167 });
168
169});
170
171})(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.