homeflowjs 0.13.6 → 0.13.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.13.6",
3
+ "version": "0.13.8",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -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')),
@@ -283,9 +304,11 @@ export default class GeonamesMap extends DraggableMap {
283
304
  marker.on('mouseover', (e) => {
284
305
  if (!marker?.property) return;
285
306
 
307
+ const geoPopup = Homeflow.get('custom_geo_popup') || this.popup;
308
+
286
309
  L.popup({ closeButton: false, offset: [0, -40] })
287
310
  .setLatLng(e.latlng)
288
- .setContent(this.popup(marker))
311
+ .setContent(geoPopup(marker))
289
312
  .openOn(this.map)
290
313
  });
291
314