homeflowjs 0.13.11 → 0.13.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -48,6 +48,13 @@ export default class GeonamesMap extends DraggableMap {
|
|
48
48
|
const prevProperties = store.getState().properties.properties;
|
49
49
|
|
50
50
|
this.unsubscribeFromGeonamesChanges = store.subscribe(() => {
|
51
|
+
const zoomLevel = this.map.getZoom();
|
52
|
+
/*
|
53
|
+
* Unsubscribe if the user has zoomed from the initial position as this
|
54
|
+
* was causing the map to zoom back to it's inital position
|
55
|
+
*/
|
56
|
+
if (window.initialZoomLevel && window.initialZoomLevel !== zoomLevel) return this.unsubscribeFromGeonamesChanges();
|
57
|
+
|
51
58
|
const { geonames, properties } = store.getState().properties
|
52
59
|
|
53
60
|
if (properties?.length) this.geonamesInit();
|
@@ -78,7 +85,14 @@ export default class GeonamesMap extends DraggableMap {
|
|
78
85
|
* If for some reason the markers have not rendered after a few seconds
|
79
86
|
* render them so we don't have an empty map
|
80
87
|
*/
|
81
|
-
setTimeout(() => {
|
88
|
+
const geoNamesTimer = setTimeout(() => {
|
89
|
+
const zoomLevel = this.map.getZoom();
|
90
|
+
/*
|
91
|
+
* Cancel timer if the user has zoomed from the initial position as this
|
92
|
+
* was causing the map to zoom back to it's inital position
|
93
|
+
*/
|
94
|
+
if (window.initialZoomLevel && window.initialZoomLevel !== zoomLevel) return cancelGeonamesTimer();
|
95
|
+
|
82
96
|
if (!this.markersInitialized) {
|
83
97
|
const { geonames, properties } = store.getState().properties
|
84
98
|
if (!properties && !geonames?.length) {
|
@@ -93,6 +107,10 @@ export default class GeonamesMap extends DraggableMap {
|
|
93
107
|
this.setToMarkeredBounds();
|
94
108
|
}
|
95
109
|
}, 5000);
|
110
|
+
|
111
|
+
function cancelGeonamesTimer() {
|
112
|
+
clearTimeout(geoNamesTimer);
|
113
|
+
}
|
96
114
|
}
|
97
115
|
|
98
116
|
setMarkerTypeforZoomLevel() {
|
@@ -172,6 +190,7 @@ export default class GeonamesMap extends DraggableMap {
|
|
172
190
|
|
173
191
|
this.setMarkers();
|
174
192
|
this.setToMarkeredBounds();
|
193
|
+
if (!window.initialZoomLevel) window.initialZoomLevel = this.map.getZoom();
|
175
194
|
|
176
195
|
const zoomLevel = this.map.getZoom();
|
177
196
|
|
@@ -190,13 +209,13 @@ export default class GeonamesMap extends DraggableMap {
|
|
190
209
|
}
|
191
210
|
|
192
211
|
getMarkerBounds() {
|
193
|
-
const
|
212
|
+
const polygon = store.getState().search.currentSearch?.place?.polygon;
|
194
213
|
if (this.viewport) {
|
195
214
|
const viewportBounds = this.getViewportBounds();
|
196
215
|
if (viewportBounds.flat().find(coordinate => coordinate === Infinity)) return null;
|
197
216
|
|
198
217
|
return L.latLngBounds(...viewportBounds.map(bound => L.latLng(...bound)));
|
199
|
-
} else if (polygon && polygon
|
218
|
+
} else if (polygon && polygon?.length) {
|
200
219
|
const polyBounds = [this.getTopRightPolygonCoordinates(polygon[0]), this.getBottomLeftPolygonCoordinates(polygon[0])];
|
201
220
|
const options = Homeflow.get('custom_map_bounds_padding')
|
202
221
|
const latLongBounds = L.latLngBounds(...polyBounds.map(bound => L.latLng(...bound)));
|