homeflowjs 0.12.4 → 0.12.6

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,11 +1,12 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "properties/properties-map/**/*",
7
7
  "properties/property-map/**/*",
8
- "properties/property-streetview/**/*"
8
+ "properties/property-streetview/**/*",
9
+ "properties/stamp-duty-calculator/**/*"
9
10
  ],
10
11
  "description": "JavaScript toolkit for Homeflow themes",
11
12
  "main": "index.js",
@@ -59,7 +59,7 @@ export default class DraggableMap {
59
59
  this.buildPolygon();
60
60
  this.setMarkers();
61
61
  if (this.noLocationfound || Homeflow.get('breadcrumbs_map')) { this.setToMarkeredBounds(); }
62
- if (Homeflow.get('custom_map_zoom') !== null) {
62
+ if (Homeflow.get('custom_map_zoom')) {
63
63
  this.map.setZoom(Homeflow.get('custom_map_zoom'));
64
64
  }
65
65
  }
@@ -293,6 +293,12 @@ export default class DraggableMap {
293
293
  }
294
294
 
295
295
  setToMarkeredBounds() {
296
+ const viewport = store.getState().search.currentSearch.place?.viewport;
297
+
298
+ if (viewport && this.viewport !== viewport) {
299
+ this.viewport = viewport;
300
+ }
301
+
296
302
  const options = Homeflow.get('custom_map_bounds_padding');
297
303
  const bounds = this.getMarkerBounds();
298
304
 
@@ -311,27 +317,38 @@ export default class DraggableMap {
311
317
  if (this.bounds && this.bounds.isValid()) {
312
318
  return this.bounds;
313
319
  } else {
314
- const bounds = [this.getTopLeftMarkerCoordinates(), this.getBottomRightMarkerCoordinates()];
315
- if (bounds.flat().find(coordinate => coordinate === Infinity)) return null;
320
+ if (Homeflow.get('breadcrumbs_map')) {
321
+ const viewportBounds = this.getViewportBounds();
322
+ if (viewportBounds.flat().find(coordinate => coordinate === Infinity)) return null;
323
+
324
+ return L.latLngBounds(...viewportBounds.map(bound => L.latLng(...bound)));
325
+ } else {
326
+ const bounds = [this.getTopRightMarkerCoordinates(), this.getBottomLeftMarkerCoordinates()];
327
+ if (bounds.flat().find(coordinate => coordinate === Infinity)) return null;
316
328
 
317
- return L.latLngBounds(...bounds.map(bound => L.latLng(...bound)));
329
+ return L.latLngBounds(...bounds.map(bound => L.latLng(...bound)));
330
+ }
318
331
  }
319
332
  }
320
333
 
321
- getTopLeftMarkerCoordinates() {
322
- return [
323
- Math.min(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lat')),
324
- Math.min(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lng'))
325
- ];
334
+ getViewportBounds() {
335
+ return [...this.viewport[0].filter((coords, index) => index === 0 || index === 2).map(coords => [...coords.toReversed()])];
326
336
  }
327
337
 
328
- getBottomRightMarkerCoordinates() {
338
+ getTopRightMarkerCoordinates() {
329
339
  return [
330
340
  Math.max(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lat')),
331
341
  Math.max(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lng'))
332
342
  ];
333
343
  }
334
344
 
345
+ getBottomLeftMarkerCoordinates() {
346
+ return [
347
+ Math.min(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lat')),
348
+ Math.min(...this.parseCoordinateArray([this.properties, this.breadcrumbs].flat(), 'lng'))
349
+ ];
350
+ }
351
+
335
352
  parseCoordinateArray(items, coordinateType) {
336
353
  if (!items) return [];
337
354
 
@@ -444,9 +461,12 @@ export default class DraggableMap {
444
461
  url = `/search.ljson?${buildQueryString(this.getSearch())}/view-${bounds.toBBoxString()}&count=50`;
445
462
  } else {
446
463
  // unset place
447
- store.dispatch(setPlace(null));
464
+ // Leaving this commented as it may be needed
465
+ // It is causing issues as the place state is never reset after the request
466
+ // so the place is just empty
467
+ // Not sure it has to be set to null for the request to work
468
+ // store.dispatch(setPlace(null));
448
469
  const newSearch = this.getSearch();
449
- newSearch.place = null;
450
470
  url = `/search.ljson?${buildQueryString(newSearch)}/view-${bounds.toBBoxString()}&count=50`;
451
471
  }
452
472
  if (Homeflow.get('get_geo_features')) {
@@ -708,6 +728,7 @@ export default class DraggableMap {
708
728
  if (breadcrumbs && this.breadcrumbs !== breadcrumbs) {
709
729
  this.breadcrumbs = breadcrumbs;
710
730
  this.setMarkers();
731
+ this.setToMarkeredBounds();
711
732
  }
712
733
  }
713
734
  }
@@ -8,20 +8,10 @@ const PropertyStreetview = ({ initGoogleMaps, ...otherProps }) => {
8
8
  const initializeMap = () => {
9
9
  // Should this be added to Redux?
10
10
  const property = Homeflow.get('property');
11
-
12
- const panorama = new google.maps.StreetViewPanorama(document.getElementById('hfjs-property-streetview'));
13
- panorama.setPosition(new google.maps.LatLng(property.lat, property.lng));
14
-
15
- if (property.streetview) {
16
- const { pitch, heading } = property.streetview.orientation;
17
- const { lat, lng } = property.streetview.position;
18
-
19
- panorama.setPosition(new google.maps.LatLng(lat, lng));
20
- panorama.setPov({ heading, pitch });
21
- } else {
22
- panorama.setPosition(new google.maps.LatLng(property.lat, property.lng));
23
- }
24
-
11
+ const panorama = new google.maps.StreetViewPanorama(document.getElementById('hfjs-property-streetview'), {
12
+ position: {lat: property.lat, lng: property.lng},
13
+ pov: {heading: 0, pitch: 0}
14
+ });
25
15
  panorama.setVisible(true);
26
16
  };
27
17
 
@@ -11,6 +11,7 @@ const INITIAL_STATE = {
11
11
  tags: [],
12
12
  poly: '',
13
13
  auctionDate: '',
14
+ viewport: [],
14
15
  },
15
16
  initialSearch: {}, // original search when the page first loads
16
17
  savedSearches: [],
@@ -120,8 +121,11 @@ const searchReducer = (state = INITIAL_STATE, action) => {
120
121
  if (!place) {
121
122
  return {
122
123
  ...state,
123
- place: null,
124
- placeId: null,
124
+ currentSearch: {
125
+ ...state.currentSearch,
126
+ place: null,
127
+ placeId: null,
128
+ }
125
129
  };
126
130
  }
127
131