PageSourceSearch

https://niceforyou.ru/wp-content/themes/nice/js/acfmap.js?ver=1.0.0

js niceforyou.ru collected 2026-10-06 12:30:20 UTC 2,671 bytes, 170 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	};
28	
29	
30	// create map	        	
31	var map = new google.maps.Map( $el[0], args);
32	
33	
34	// add a markers reference
35	map.markers = [];
36	
37	
38	// add markers
39	$markers.each(function(){
40		
41    	add_marker( $(this), map );
42		
43	});
44	
45	
46	// center map
47	center_map( map );
48	
49	
50	// return
51	return map;
52	
53}
54
55/*
56*  add_marker
57*
58*  This function will add a marker to the selected Google Map
59*
60*  @type	function
61*  @date	8/11/2013
62*  @since	4.3.0
63*
64*  @param	$marker (jQuery element)
65*  @param	map (Google Map object)
66*  @return	n/a
67*/
68
69function add_marker( $marker, map ) {
70
71	// var
72	var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
73
74	// create marker
75	var marker = new google.maps.Marker({
76		position	: latlng,
77		map			: map
78	});
79
80	// add to array
81	map.markers.push( marker );
82
83	// if marker contains HTML, add it to an infoWindow
84	if( $marker.html() )
85	{
86		// create info window
87		var infowindow = new google.maps.InfoWindow({
88			content		: $marker.html()
89		});
90
91		// show info window when marker is clicked
92		google.maps.event.addListener(marker, 'click', function() {
93
94			infowindow.open( map, marker );
95
96		});
97		//infowindow.open( map, marker );
98	}
99
100}
101
102/*
103*  center_map
104*
105*  This function will center the map, showing all markers attached to this map
106*
107*  @type	function
108*  @date	8/11/2013
109*  @since	4.3.0
110*
111*  @param	map (Google Map object)
112*  @return	n/a
113*/
114
115function center_map( map ) {
116
117	// vars
118	var bounds = new google.maps.LatLngBounds();
119
120	// loop through all markers and create bounds
121	$.each( map.markers, function( i, marker ){
122
123		var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
124
125		bounds.extend( latlng );
126
127	});
128
129	// only 1 marker?
130	if( map.markers.length == 1 )
131	{
132		// set center of map
133	    map.setCenter( bounds.getCenter() );
134	    map.setZoom( 16 );
135	}
136	else
137	{
138		// fit to bounds
139		map.fitBounds( bounds );
140	}
141
142}
143
144/*
145*  document ready
146*
147*  This function will render each map when the document is ready (page has loaded)
148*
149*  @type	function
150*  @date	8/11/2013
151*  @since	5.0.0
152*
153*  @param	n/a
154*  @return	n/a
155*/
156// global var
157var map = null;
158
159$(document).ready(function(){
160
161	$('.acf-map').each(function(){
162
163		// create map
164		map = new_map( $(this) );
165
166	});
167
168});
169
170})(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.