PageSourceSearch

https://www.adactive.co.il/wp-content/themes/adactive/assets/js/gmaps.js

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