PageSourceSearch

https://skyrealestate.co/wp-content/themes/homeo/js/property-map.js?ver=20150330

js skyrealestate.co collected 2026-10-04 13:25:34 UTC 14,569 bytes, 341 lines download raw bytes

1(function($) {
2    "use strict";
3    
4    var map, mapSidebar, markers, CustomHtmlIcon, group;
5    var markerArray = [];
6
7    $.extend($.apusThemeCore, {
8        /**
9         *  Initialize scripts
10         */
11        property_map_init: function() {
12            var self = this;
13
14            if ($('#properties-google-maps').length) {
15                L.Icon.Default.imagePath = 'wp-content/themes/homeo/images/';
16            }
17            
18            setTimeout(function(){
19                
20                self.mapInit('properties-google-maps');
21                self.mapInit('single-property-google-maps');
22                self.initStreetView();
23
24                self.getProperties('properties-google-maps');
25            }, 50);
26            
27        },
28        getProperties: function(map_e_id) {
29            var self = this;
30            if ( $('.widget-properties-maps .properties-google-maps').length ) {
31                $('.widget-properties-maps .properties-google-maps').each(function(e){
32                    var $this = $(this);
33                    
34                    $this.addClass('loading');
35                    var $settings = $(this).data('settings');
36
37                    var ajaxurl = homeo_property_opts.ajaxurl;
38                    if ( typeof wp_realestate_opts.ajaxurl_endpoint !== 'undefined' ) {
39                        var ajaxurl =  wp_realestate_opts.ajaxurl_endpoint.toString().replace( '%%endpoint%%', 'homeo_get_ajax_properties' );
40                    }
41                    
42                    $.ajax({
43                        url: ajaxurl,
44                        type:'POST',
45                        dataType: 'html',
46                        data: {
47                            action: 'homeo_get_ajax_properties',
48                            settings: $settings,
49                        }
50                    }).done(function(data) {
51                        $this.removeClass('loading');
52                        $this.closest('.widget-properties-maps').find('.main-items-wrapper').html(data);
53                        setTimeout(function(){
54                            self.updateMakerCards(map_e_id);
55                        });
56                    });
57                });
58            }
59        },
60        mapInit: function(map_e_id) {
61            var self = this;
62
63            var $window = $(window);
64
65            if (!$('#' + map_e_id).length) {
66                return;
67            }
68
69            map = L.map(map_e_id, {
70                scrollWheelZoom: false
71            });
72
73            markers = new L.MarkerClusterGroup({
74                showCoverageOnHover: false
75            });
76
77            CustomHtmlIcon = L.HtmlIcon.extend({
78                options: {
79                    html: "<div class='map-popup'></div>",
80                    iconSize: [38, 50],
81                    iconAnchor: [19, 50],
82                    popupAnchor: [0, -40]
83                }
84            });
85
86            $window.on('pxg:refreshmap', function() {
87                map._onResize();
88                setTimeout(function() {
89                    
90                    if(markerArray.length > 0 ){
91                        group = L.featureGroup(markerArray);
92                        map.fitBounds(group.getBounds()); 
93                    }
94                }, 100);
95            });
96
97            $window.on('pxg:simplerefreshmap', function() {
98                map._onResize();
99            });
100
101            $('.tabs-gallery-map .nav-tabs .tab-google-map').on('click', function(){
102                window.dispatchEvent(new Event('resize'));
103                
104            });
105
106            if ( homeo_property_map_opts.map_service == 'mapbox' ) {
107                var tileLayer = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/'+homeo_property_map_opts.mapbox_style+'/tiles/{z}/{x}/{y}?access_token='+ homeo_property_map_opts.mapbox_token, {
108                    attribution: " &copy;  <a href='https://www.mapbox.com/about/maps/'>Mapbox</a> &copy;  <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>",
109                    maxZoom: 18,
110                });
111            } else if ( homeo_property_map_opts.map_service == 'here' ) {
112
113                var hereTileUrl = 'https://2.base.maps.ls.hereapi.com/ma
113ptile/2.1/maptile/newest/'+homeo_property_map_opts.here_style+'/{z}/{x}/{y}/512/png8?apiKey='+ homeo_property_map_opts.here_map_api_key +'&ppi=320';
114                var tileLayer = L.tileLayer(hereTileUrl, {
115                    attribution: " &copy;  <a href='https://www.mapbox.com/about/maps/'>Here</a> &copy; <strong><a href='https://www.mapbox.com/map-feedback/' target='_blank'>Improve this map</a></strong>",
116                    maxZoom: 18,
117                });
118
119            } else if ( homeo_property_map_opts.map_service == 'openstreetmap' ) {
120                
121                var tileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
122                    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
123                });
124
125            } else {
126                if ( homeo_property_map_opts.custom_style != '' ) {
127                    try {
128                        var custom_style = $.parseJSON(homeo_property_map_opts.custom_style);
129                        var tileLayer = L.gridLayer.googleMutant({
130                            type: homeo_property_map_opts.googlemap_type,
131                            styles: custom_style
132                        });
133                    } catch(err) {
134                        var tileLayer = L.gridLayer.googleMutant({
135                            type: homeo_property_map_opts.googlemap_type
136                        });
137                    }
138                } else {
139                    var tileLayer = L.gridLayer.googleMutant({
140                        type: homeo_property_map_opts.googlemap_type
141                    });
142                }
143                $('#apus-listing-map').addClass('map--google');
144            }
145
146            map.addLayer(tileLayer);
147
148            // check archive/single page
149            if ( !$('#'+map_e_id).is('.single-property-map') ) {
150                self.updateMakerCards(map_e_id);
151            } else {
152                var $item = $('.single-listing-wrapper');
153                
154                if ( $item.data('latitude') !== "" && $item.data('latitude') !== "" ) {
155                    var zoom = (typeof MapWidgetZoom !== "undefined") ? MapWidgetZoom : 15;
156                    self.addMakerToMap($item);
157                    map.addLayer(markers);
158                    map.setView([$item.data('latitude'), $item.data('longitude')], zoom);
159                    $(window).on('update:map', function() {
160                        map.setView([$item.data('latitude'), $item.data('longitude')], zoom);
161                    });
162
163                    $('.location-map-view').on('click', function(e){
164                        e.preventDefault();
165                        $('#single-property-street-view-map').hide();
166                        $('#'+map_e_id).show();
167                        $('.location-street-view').removeClass('hidden');
168                        $(this).removeClass('hidden').addClass('hidden');
169                        map._onResize();
170                    });
171
172                } else {
173                    $('#' + map_e_id).hide();
174                }
175            }
176        },
177        updateMakerCards: function(map_e_id) {
178            var self = this;
179            var $items = $('.main-items-wrapper .map-item');
180
181            if ($('#' + map_e_id).length && typeof map !== "undefined") {
182                
183                if (!$items.length) {
184                    map.setView([homeo_property_map_opts.default_latitude, homeo_property_map_opts.default_longitude], 12);
185                    return;
186                }
187
188                map.removeLayer(markers);
189                markers = new L.MarkerClusterGroup({
190                    showCoverageOnHover: false
191                });
192                $items.each(function(i, obj) {
193                    self.addMakerToMap($(obj), true);
194                });
195
196                map.addLayer(markers);
197
198                if(markerArray.length > 0 ){
199                    group = L.featureGroup(markerArray);
200                    map.fitBounds(group.getBounds()); 
201                }
202            }
203        },
204        addMakerToMap: function($item, archive) {
205            var self = this;
206            var marker;
207
208            if ( $item.data('latitude') == "" || $item.data('longitude') == "") {
209                return;
210            }
211            
212            if(homeo_property_map_opts.default_pin){
213                var img_agency = "<img src='" + homeo_property_map_opts.default_pin + "'>";
214            }else{
215                var img_agency = '<i class="fas fa-map-marker-alt"></i>';
216            }
217            var mapPinHTML = "<div class='map-popup'><div class='icon-wrapper has-img'>" + img_agency + "</div></div>";
218            
219
220            marker = L.marker([$item.data('latitude'), $item.data('longitude')], {
221                icon: new CustomHtmlIcon({ html: mapPinHTML })
222            });
223
224            if (typeof archive !== "undefined") {
225                
226                $item.hover(function() {
227                    $(marker._icon).find('.map-popup').addClass('map-popup-selected');
228                }, function() {
229                    $(marker._icon).find('.map-popup').removeClass('map-popup-selected');
230                });
231
232                var customOptions = {
233                    'maxWidth': '290',
234                };
235
236                var logo_html = '';
237                if ( $item.data('img') ) {
238                    logo_html =  "<div class='image-wrapper image-loaded'>" +
239                                "<img src='" + $item.data('img') + "'>" +
240                            "</div>";
241                }
242
243                var title_html = '';
244                if ( $item.find('.property-title').length ) {
245                    title_html = "<h3 class='property-title'>" + $item.find('.property-title').html() + "</h3>";
246                } else if ( $item.find('.agency-title').length ) {
247                    title_html = "<h3 class='property-title agency-title'>" + $item.find('.agency-title').html() + "</h3>";
248                }
249
250
251                var price_html = '';
252                if ( $item.find('.property-price').length ) {
253                    price_html = "<div class='property-price'>" + $item.find('.property-price').html() + "</div>";
254                }
255
256                var property_type = '';
257                if ( $item.find('.property-type').length ) {
258                    property_type = "<div class='property-type '>" + $item.find('.property-type').html() + "</div>";
259                }
260
261                var property_location  = '';
262                if ( $item.find('.property-location ').length ) {
263                    property_location = "<div class='property-location  '>" + $item.find('.property-location ').html() + "</div>";
264                }
265
266                var property_metas  = '';
267                if ( $item.find('.property-metas ').length ) {
268                    property_metas = "<div class='property-metas  '>" + $item.find('.property-metas ').html() + "</div>";
269                }
270
271                marker.bindPopup(
272                    "<div class='property-item property-grid'><div class='top-info'>" +
273                        "<div class='property-thumbnail-wrapper flex-middle justify-content-center'>" + logo_html +
274                            "<div class='bottom-label flex-middle'>" + price_html + "</div>" +
275                        "</div>" + 
276                        "<div class='property-information'>" + property_type + title_html + property_location + property_metas + "</div>" +
277                    "</div></div>", customOptions).openPopup();
278            }
279
280            markers.addLayer(marker);
281            markerArray.push(L.marker([$item.data('latitude'), $item.data('longitude')]));
282        },
283        initStreetView: function() {
284            var panorama = null;
285            
286            $('.tab-google-street-view-map').on('click', function(e){
287                e.preventDefault();
288                //$('#single-tab-property-street-view-map').show();
289
290                var $item = $('.single-listing-wrapper');
291
292                if ( $item.data('latitude') !== "" && $item.data('longitude') !== "") {
293                    var zoom = (typeof MapWidgetZoom !== "undefined") ? MapWidgetZoom : 15;
294                    
295                    if ( panorama == null ) {
296                        var fenway = new google.maps.LatLng($item.data('latitude'),$item.data('longitude'));
297                        var panoramaOptions = {
298                            position: fenway,
299                            pov: {
300                                heading: 34,
301                                pitch: 10
302                            }
303                        };
304                        panorama = new  google.maps.StreetViewPanorama(document.getElementById('single-tab-property-street-view-map'),panoramaOptions);
305                    }
306                }
307            });
308
309            $('.location-street-view').on('click', function(e){
310                e.preventDefault();
311                $('#single-property-street-view-map').show();
312                $('#single-property-google-maps').hide();
313                $(this).removeClass('hidden').addClass('hidden');
314                $('.location-map-view').removeClass('hidden');
315
316                var $item = $('.single-listing-wrapper');
317
318                if ( $item.data('latitude') !== "" && $item.data('longitude') !== "") {
319                    var zoom = (typeof MapWidgetZoom !== "undefined") ? MapWidgetZoom : 15;
320                    
321                    if ( panorama == null ) {
322                        var fenway = new google.maps.LatLng($item.data('latitude'),$item.data('longitude'));
323                        var panoramaOptions = {
324                            position: fenway,
325                            pov: {
326                                heading: 34,
327                                pitch: 10
328                            }
329                        };
330                        panorama = new  google.maps.StreetViewPanorama(document.getElementById('single-property-street-view-map'),panoramaOptions);
331                    }
332                }
333            });
334        }
335
336    });
337
338    $.apusThemeExtensions.property_map = $.apusThemeCore.property_map_init;
339
340    
341})(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.