homeflowjs 0.12.3 → 0.12.5
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/branches/branch-map/branch-map.component.jsx +2 -0
- package/package.json +7 -1
- package/properties/properties-map/draggable-map.js +33 -12
- package/properties/property-map/property-map.component.jsx +2 -0
- package/properties/property-streetview/property-streetview.component.jsx +4 -14
- package/reducers/search.reducer.js +6 -2
@@ -8,6 +8,8 @@ import { simpleBW } from '../../shared/custom-gmap-styles';
|
|
8
8
|
|
9
9
|
const BranchLeafletMap = React.lazy(() => import('./branch-leaflet-map.component'));
|
10
10
|
|
11
|
+
import 'leaflet/dist/leaflet.css';
|
12
|
+
|
11
13
|
const LazyLeafletMap = (props) => (
|
12
14
|
<Suspense fallback={<div>Loading</div>}>
|
13
15
|
<BranchLeafletMap {...props} />
|
package/package.json
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "homeflowjs",
|
3
|
-
"version": "0.12.
|
3
|
+
"version": "0.12.5",
|
4
|
+
"sideEffects": [
|
5
|
+
"modal/**/*",
|
6
|
+
"properties/properties-map/**/*",
|
7
|
+
"properties/property-map/**/*",
|
8
|
+
"properties/property-streetview/**/*"
|
9
|
+
],
|
4
10
|
"description": "JavaScript toolkit for Homeflow themes",
|
5
11
|
"main": "index.js",
|
6
12
|
"scripts": {
|
@@ -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')
|
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
|
-
|
315
|
-
|
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
|
-
|
329
|
+
return L.latLngBounds(...bounds.map(bound => L.latLng(...bound)));
|
330
|
+
}
|
318
331
|
}
|
319
332
|
}
|
320
333
|
|
321
|
-
|
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
|
-
|
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
|
-
|
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
|
}
|
@@ -6,6 +6,8 @@ import PropTypes from 'prop-types';
|
|
6
6
|
import { initGoogleMaps } from '../../actions/app.actions';
|
7
7
|
import { simpleBW } from '../../shared/custom-gmap-styles';
|
8
8
|
|
9
|
+
import '../properties-map/leaflet.css';
|
10
|
+
|
9
11
|
const PropertyLeafletMap = React.lazy(() => import('./property-leaflet-map.component'));
|
10
12
|
|
11
13
|
const LazyLeafletMap = (props) => (
|
@@ -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
|
-
|
13
|
-
|
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
|
-
|
124
|
-
|
124
|
+
currentSearch: {
|
125
|
+
...state.currentSearch,
|
126
|
+
place: null,
|
127
|
+
placeId: null,
|
128
|
+
}
|
125
129
|
};
|
126
130
|
}
|
127
131
|
|