PageSourceSearch

https://realmarka.com.br/wp-content/themes/realhomes/assets/modern…/properties-open-street-map.js?ver=3.13.1

js realmarka.com.br collected 2026-09-29 12:21:27 UTC 4,738 bytes, 150 lines download raw bytes

1/**
2 * Javascript to handle open street map for multiple properties
3 */
4(function ($) {
5    "use strict";
6
7	if ( typeof propertiesMapData !== "undefined" ) {
8
9		if ( 0 < propertiesMapData.length ) {
10
11			var tileLayer = L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
12				attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
13			} );
14
15			// get map bounds
16			var mapBounds = [];
17			for( var i = 0; i < propertiesMapData.length; i++ ) {
18				if ( propertiesMapData[i].lat && propertiesMapData[i].lng ) {
19					mapBounds.push( [ propertiesMapData[i].lat, propertiesMapData[i].lng ] );
20				}
21			}
22
23			// Basic map
24			var mapCenter = L.latLng( 27.664827, -81.515755 );	// given coordinates not going to matter 99.9% of the time but still added just in case.
25			if ( 1 == mapBounds.length ) {
26				mapCenter = L.latLng( mapBounds[0] );	// this is also not going to effect 99% of the the time but just in case of one property.
27			}
28			var mapDragging = (L.Browser.mobile) ? false : true; // disabling one finger dragging on mobile but zoom with two fingers will still be enabled.
29			var mapOptions = {
30				dragging: mapDragging,
31				center: mapCenter,
32				zoom: 10,
33				zoomControl: false,
34				tap: false,
35				layers: [tileLayer]
36			};
37			var propertiesMap = L.map( 'listing-map', mapOptions );
38
39			L.control.zoom( {
40				position : 'bottomleft'
41			} ).addTo( propertiesMap );
42
43			propertiesMap.scrollWheelZoom.disable();
44
45			if ( 1 < mapBounds.length ) {
46				propertiesMap.fitBounds( mapBounds );	// fit bounds should work only for more than one properties
47			}
48
49			var markers = L.markerClusterGroup({
50				chunkedLoading: true,
51				//singleMarkerMode: true,
52				spiderfyOnMaxZoom: true
53			});
54
55			for( var i = 0; i < propertiesMapData.length; i++ ) {
56
57				if ( propertiesMapData[i].lat && propertiesMapData[i].lng ) {
58
59					var propertyMapData = propertiesMapData[i];
60
61					var markerLatLng = L.latLng( propertyMapData.lat, propertyMapData.lng );
62
63					var markerOptions = {
64						riseOnHover: true
65					};
66
67					// Marker icon
68					if ( propertyMapData.title ) {
69						markerOptions.title = propertyMapData.title;
70					}
71
72					// Marker icon
73					if ( propertyMapData.icon ) {
74						var iconOptions = {
75							iconUrl: propertyMapData.icon,
76							iconSize: [42, 57],
77							iconAnchor: [20, 57],
78							popupAnchor: [1, -54]
79						};
80						if ( propertyMapData.retinaIcon ) {
81							iconOptions.iconRetinaUrl = propertyMapData.retinaIcon;
82						}
83						markerOptions.icon = L.icon( iconOptions );
84					}
85
86					var propertyMarker = L.marker( markerLatLng, markerOptions );
87
88					// Marker popup
89					var popupContentWrapper = document.createElement( "div" );
90					popupContentWrapper.className = 'osm-popup-content';
91					var popupContent = "";
92
93					if( propertyMapData.thumb ) {
94						popupContent += '<a class="osm-popup-thumb-link" href="' + propertyMapData.url + '"><img class="osm-popup-thumb" src="' + propertyMapData.thumb + '" alt="' + propertyMapData.title + '"/></a>';
95					}
96
97					if ( propertyMapData.title ) {
98						popupContent += '<h5 class="osm-popup-title"><a class="osm-popup-link" href="' + propertyMapData.url + '">' + propertyMapData.title + '</a></h5>';
99					}
100
101					if( propertyMapData.price ) {
102						popupContent += '<p><span class="osm-popup-price">' + propertyMapData.price + '</span></p>';
103					}
104
105					popupContentWrapper.innerHTML = popupContent;
106
107					propertyMarker.popupContents = popupContentWrapper;
108
109					propertyMarker.bindPopup( popupContentWrapper );
110
111					markers.addLayer(propertyMarker);
112
113				}
114			}
115
116			propertiesMap.addLayer( markers );
117
118		} else {
119
120			// Fallback Map in Case of No Properties
121			var fallbackLayer = 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			var fallback_lat, fallback_lng;
126			if (undefined !== propertiesMapOptions.fallback_location && propertiesMapOptions.fallback_location.lat && propertiesMapOptions.fallback_location.lng) {
127				fallback_lat = propertiesMapOptions.fallback_location.lat;
128				fallback_lng = propertiesMapOptions.fallback_location.lng;
129			} else {
130				// Default location of Florida in fallback map.
131				fallback_lat = '27.664827';
132				fallback_lng = '-81.515755';
133			}
134
135			var fallbackMapOptions = {
136				center : [fallback_lat, fallback_lng],
137				zoom : 12
138			};
139
140			var fallbackMap = L.map( 'listing-map', fallbackMapOptions );
141			fallbackMap.addLayer( fallbackLayer );
142
143		}
144
145	}
146
147	// Add custom class to zoom control to apply z-index for modern variation
148	$(".leaflet-control-zoom").parent(".leaflet-bottom").addClass("rh_leaflet_controls_zoom");
149
150})(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.