homeflowjs 0.13.5 → 0.13.7
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
@@ -190,16 +190,37 @@ export default class GeonamesMap extends DraggableMap {
|
|
190
190
|
}
|
191
191
|
|
192
192
|
getMarkerBounds() {
|
193
|
+
const { polygon } = store.getState().search.currentSearch?.place;
|
193
194
|
if (this.viewport) {
|
194
195
|
const viewportBounds = this.getViewportBounds();
|
195
196
|
if (viewportBounds.flat().find(coordinate => coordinate === Infinity)) return null;
|
196
197
|
|
197
198
|
return L.latLngBounds(...viewportBounds.map(bound => L.latLng(...bound)));
|
199
|
+
} else if (polygon && polygon.length) {
|
200
|
+
const polyBounds = [this.getTopRightPolygonCoordinates(polygon[0]), this.getBottomLeftPolygonCoordinates(polygon[0])];
|
201
|
+
const options = Homeflow.get('custom_map_bounds_padding')
|
202
|
+
const latLongBounds = L.latLngBounds(...polyBounds.map(bound => L.latLng(...bound)));
|
203
|
+
|
204
|
+
this.map.fitBounds(latLongBounds, options);
|
198
205
|
} else {
|
199
206
|
return super.getMarkerBounds();
|
200
207
|
}
|
201
208
|
}
|
202
209
|
|
210
|
+
getTopRightPolygonCoordinates(polygon) {
|
211
|
+
return [
|
212
|
+
Math.max(...polygon.map(coords => parseFloat(coords[1]))),
|
213
|
+
Math.max(...polygon.map(coords => parseFloat(coords[0])))
|
214
|
+
];
|
215
|
+
}
|
216
|
+
|
217
|
+
getBottomLeftPolygonCoordinates(polygon) {
|
218
|
+
return [
|
219
|
+
Math.min(...polygon.map(coords => parseFloat(coords[1]))),
|
220
|
+
Math.min(...polygon.map(coords => parseFloat(coords[0])))
|
221
|
+
];
|
222
|
+
}
|
223
|
+
|
203
224
|
getTopRightMarkerCoordinates() {
|
204
225
|
return [
|
205
226
|
Math.max(...this.parseCoordinateArray([this.properties, this.geonames].flat(), 'lat')),
|
@@ -252,6 +273,18 @@ export default class GeonamesMap extends DraggableMap {
|
|
252
273
|
this.propertiesLayer.addTo(this.map);
|
253
274
|
}
|
254
275
|
|
276
|
+
popup(marker) {
|
277
|
+
const formatter = Intl.NumberFormat('en', { notation: 'compact' });
|
278
|
+
const priceValue = marker?.property?.price_value;
|
279
|
+
const formattedPrice = priceValue ? formatter.format(priceValue) : null;
|
280
|
+
|
281
|
+
if (!priceValue) return;
|
282
|
+
|
283
|
+
return `
|
284
|
+
<div class="geomap__property-popup">£${formattedPrice}</div>
|
285
|
+
`;
|
286
|
+
}
|
287
|
+
|
255
288
|
generateMarker(propertyOrGeoname) {
|
256
289
|
const marker = L.marker(
|
257
290
|
[propertyOrGeoname.lat, propertyOrGeoname.lng],
|
@@ -268,6 +301,15 @@ export default class GeonamesMap extends DraggableMap {
|
|
268
301
|
}
|
269
302
|
});
|
270
303
|
|
304
|
+
marker.on('mouseover', (e) => {
|
305
|
+
if (!marker?.property) return;
|
306
|
+
|
307
|
+
L.popup({ closeButton: false, offset: [0, -40] })
|
308
|
+
.setLatLng(e.latlng)
|
309
|
+
.setContent(this.popup(marker))
|
310
|
+
.openOn(this.map)
|
311
|
+
});
|
312
|
+
|
271
313
|
if (Homeflow.get('show_geoname_polygon_on_mouseover') && propertyOrGeoname.polygon?.length) {
|
272
314
|
marker.on('mouseover', () => this.geonameMarkerMouseOver(marker));
|
273
315
|
marker.on('mouseout', () => this.geonameMarkerMouseOut(marker));
|