PageSourceSearch

https://thehighlighthouston.com/wp-content/themes/highlight/js/maps.js?ver=1

js thehighlighthouston.com collected 2026-10-06 19:16:18 UTC 3,357 bytes, 182 lines download raw bytes

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    
51    // return
52    return map;
53    
54}
55
56/*
57*  add_marker
58*
59*  This function will add a marker to the selected Google Map
60*
61*  @type    function
62*  @date    8/11/2013
63*  @since   4.3.0
64*
65*  @param   $marker (jQuery element)
66*  @param   map (Google Map object)
67*  @return  n/a
68*/
69
70function add_marker( $marker, map ) {
71
72    // var
73    var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
74    var templateURL = (directory_uri.stylesheet_directory_uri) += '/images/mapPin.svg';
75
76    // create marker
77    var icon = {
78        url: templateURL, // url
79        scaledSize: new google.maps.Size(28, 35), // scaled size
80        origin: new google.maps.Point(0,0), // origin
81        anchor: new google.maps.Point(0, 0) // anchor
82    };
83    var marker = new google.maps.Marker({
84        position    : latlng,
85        map: map,
86        icon: icon
87    });
88
89
90
91
92
93    // add to array
94    map.markers.push( marker );
95
96    // if marker contains HTML, add it to an infoWindow
97    if( $marker.html() )
98    {
99        // create info window
100        var infowindow = new google.maps.InfoWindow({
101            content     : $marker.html()
102        });
103
104        // show info window when marker is clicked
105        google.maps.event.addListener(marker, 'click', function() {
106
107            infowindow.open( map, marker );
108
109        });
110    }
111
112}
113
114/*
115*  center_map
116*
117*  This function will center the map, showing all markers attached to this map
118*
119*  @type    function
120*  @date    8/11/2013
121*  @since   4.3.0
122*
123*  @param   map (Google Map object)
124*  @return  n/a
125*/
126
127function center_map( map ) {
128
129    // vars
130    var bounds = new google.maps.LatLngBounds();
131
132    // loop through all markers and create bounds
133    $.each( map.markers, function( i, marker ){
134
135        var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
136
137        bounds.extend( latlng );
138
139    });
140
141    // only 1 marker?
142    if( map.markers.length == 1 )
143    {
144        // set center of map
145        map.setCenter( bounds.getCenter() );
146        map.setZoom( 16 );
147    }
148    else
149    {
150        // fit to bounds
151        map.fitBounds( bounds );
152    }
153
154}
155
156/*
157*  document ready
158*
159*  This function will render each map when the document is ready (page has loaded)
160*
161*  @type    function
162*  @date    8/11/2013
163*  @since   5.0.0
164*
165*  @param   n/a
166*  @return  n/a
167*/
168// global var
169var map = null;
170
171$(document).ready(function(){
172
173    $('.acf-map').each(function(){
174
175        // create map
176        map = new_map( $(this) );
177
178    });
179
180});
181
182})(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.