homeflowjs 0.11.7 → 0.11.9
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
@@ -7,6 +7,7 @@ import { buildQueryString } from '../../search/property-search/property-search';
|
|
7
7
|
import { setPlace, setSearchField } from '../../actions/search.actions';
|
8
8
|
import { setProperties, setSelectedMarker, setPagination } from '../../actions/properties.actions';
|
9
9
|
import { setLoading } from '../../actions/app.actions';
|
10
|
+
import { currentGeonameId } from '../../utils/index';
|
10
11
|
|
11
12
|
const element = function (X, Y) {
|
12
13
|
this.X = X;
|
@@ -56,7 +57,7 @@ export default class DraggableMap {
|
|
56
57
|
this.mapLoadedTimes = 1;
|
57
58
|
this.render();
|
58
59
|
this.buildPolygon();
|
59
|
-
this.
|
60
|
+
this.setMarkers();
|
60
61
|
if (this.noLocationfound) { this.setToMarkeredBounds(); }
|
61
62
|
if (Homeflow.get('custom_map_zoom') !== null) {
|
62
63
|
this.map.setZoom(Homeflow.get('custom_map_zoom'));
|
@@ -244,32 +245,46 @@ export default class DraggableMap {
|
|
244
245
|
}
|
245
246
|
}
|
246
247
|
|
247
|
-
|
248
|
-
|
249
|
-
if (this.
|
250
|
-
if (!propertiesOrBreadcrumbs) { return null }
|
248
|
+
initLayers() {
|
249
|
+
if (this.clusteringMarkerLayer) this.map.removeLayer(this.clusteringMarkerLayer);
|
250
|
+
if (this.nonClusteringMarkerLayer) this.map.removeLayer(this.nonClusteringMarkerLayer);
|
251
251
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
this.bounds
|
272
|
-
|
252
|
+
const radius = Homeflow.get('custom_clustering_radius') || 10;
|
253
|
+
|
254
|
+
this.clusteringMarkerLayer = new L.MarkerClusterGroup({ maxClusterRadius: radius, showCoverageOnHover: false });
|
255
|
+
this.nonClusteringMarkerLayer = L.featureGroup();
|
256
|
+
}
|
257
|
+
|
258
|
+
setMarkers() {
|
259
|
+
this.initLayers();
|
260
|
+
|
261
|
+
if (!this.properties && !this.breadcrumbs) { return null }
|
262
|
+
|
263
|
+
this.properties?.map(property => this.setPropertyMarker(property));
|
264
|
+
this.breadcrumbs?.map(breadcrumb => this.setBreadcrumbMarker(breadcrumb));
|
265
|
+
this.clusteringMarkerLayer.addTo(this.map);
|
266
|
+
this.nonClusteringMarkerLayer.addTo(this.map);
|
267
|
+
|
268
|
+
// TODO: Combine bounds.
|
269
|
+
this.bounds = this.clusteringMarkerLayer.getBounds() || this.nonClusteringMarkerLayer.getBounds();
|
270
|
+
|
271
|
+
return this.bounds;
|
272
|
+
}
|
273
|
+
|
274
|
+
setPropertyMarker(property) {
|
275
|
+
const geonameId = property.geoname_ids?.slice(-1)[0];
|
276
|
+
const layer = Homeflow.get('pin_clustering') ? this.clusteringMarkerLayer : this.nonClusteringMarkerLayer;
|
277
|
+
|
278
|
+
if (property.property_id === null || property.lat === 0 || property.lng === 0) return;
|
279
|
+
if (geonameId && Homeflow.get('breadcrumbs_map') && geonameId !== currentGeonameId()) return;
|
280
|
+
|
281
|
+
layer.addLayer(this.generateMarker(property));
|
282
|
+
}
|
283
|
+
|
284
|
+
setBreadcrumbMarker(breadcrumb) {
|
285
|
+
if (!breadcrumb.lat || !breadcrumb.lng) return;
|
286
|
+
|
287
|
+
this.nonClusteringMarkerLayer.addLayer(this.generateMarker(breadcrumb));
|
273
288
|
}
|
274
289
|
|
275
290
|
setToMarkeredBounds() {
|
@@ -411,7 +426,7 @@ export default class DraggableMap {
|
|
411
426
|
// if (this.tile_view != null) {
|
412
427
|
// this.tile_view = new Ctesius.Views.Tiles({ collection: this.collection });
|
413
428
|
// }
|
414
|
-
return this.
|
429
|
+
return this.setMarkers();
|
415
430
|
});
|
416
431
|
}
|
417
432
|
}
|
@@ -575,7 +590,7 @@ export default class DraggableMap {
|
|
575
590
|
// this.tile_view = new Ctesius.Views.Tiles({ collection: this.collection });
|
576
591
|
// }
|
577
592
|
|
578
|
-
return this.
|
593
|
+
return this.setMarkers();
|
579
594
|
})
|
580
595
|
// return $.get(url, (res, status, xhr) => {
|
581
596
|
// s.set('performed_data', res);
|
@@ -591,7 +606,7 @@ export default class DraggableMap {
|
|
591
606
|
// }
|
592
607
|
// else { }
|
593
608
|
// //@tile_view.collection(@collection)
|
594
|
-
// return this.
|
609
|
+
// return this.setMarkers();
|
595
610
|
// });
|
596
611
|
}
|
597
612
|
|
@@ -645,7 +660,7 @@ export default class DraggableMap {
|
|
645
660
|
|
646
661
|
if (breadcrumbs && this.breadcrumbs !== breadcrumbs) {
|
647
662
|
this.breadcrumbs = breadcrumbs;
|
648
|
-
this.
|
663
|
+
this.setMarkers();
|
649
664
|
}
|
650
665
|
}
|
651
666
|
}
|
@@ -6,11 +6,13 @@ import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet';
|
|
6
6
|
const PropertyLeafletMap = ({ CustomPopup }) => {
|
7
7
|
const property = Homeflow.get('property');
|
8
8
|
const customIcon = Homeflow.get('custom_map_icon');
|
9
|
+
const customIconAnchor = Homeflow.get('custom_map_icon_anchor');
|
9
10
|
|
10
11
|
const defaultIcon = L.icon({
|
11
12
|
iconRetinaUrl: '/assets/marker-icon.png',
|
12
13
|
iconUrl: customIcon || '/assets/marker-icon.png',
|
13
14
|
shadowUrl: '/assets/marker-shadow.png',
|
15
|
+
iconAnchor: customIconAnchor || [12, 41]
|
14
16
|
});
|
15
17
|
|
16
18
|
return (
|
package/utils/index.js
CHANGED
@@ -80,4 +80,10 @@ export const compact = (array) => array.filter((item) => typeof item !== 'undefi
|
|
80
80
|
|
81
81
|
export const sanitizeText = (string) => new Option(string).innerHTML;
|
82
82
|
|
83
|
+
export const currentGeonameId = (path) => {
|
84
|
+
const pathname = path || window.location.pathname;
|
85
|
+
const segment = pathname.split('/').reverse().find(item => item.startsWith('gid-'))?.replace(/^gid-/, '')
|
86
|
+
return parseInt(segment, 10) || null;
|
87
|
+
};
|
88
|
+
|
83
89
|
export const DEBOUNCE_DELAY = 200;
|
package/utils/index.test.js
CHANGED
@@ -19,3 +19,13 @@ describe('sanitizeText', () => {
|
|
19
19
|
expect(utils.sanitizeText('<hello>')).toEqual('<hello>');
|
20
20
|
});
|
21
21
|
});
|
22
|
+
|
23
|
+
describe('currentGeonameId', () => {
|
24
|
+
it('returns Geoname ID from path', () => {
|
25
|
+
expect(utils.currentGeonameId('/foo/bar/baz/gid-12345/qux')).toEqual(12345);
|
26
|
+
});
|
27
|
+
|
28
|
+
it('returns `null` when no Geoname ID detected', () => {
|
29
|
+
expect(utils.currentGeonameId('/foo/bar/baz/qux')).toEqual(null);
|
30
|
+
});
|
31
|
+
});
|