Closed bslipek closed 5 years ago
:+1:
Hi,
Can you post your codes here or a jsfiddle or codepen to replicate this?
Thanks
+1
+1
Here is fixed version with new way of remove layers, not perfect but works:
removeLayers() {
let layers = this.layerContainer._layers;
let layer_ids = Object.keys(layers);
layer_ids.forEach(id => {
let layer = layers[id];
if (layer._url) return; // <- prevent removing tile layer, only features group, not nice ;/
this.layerContainer.removeLayer(layer);
});
}
We still can't use markerCluster
. To do this we need to modify Leaflet
library:
// leaflet-src.js line 70
function stamp(obj) {
if (!obj) obj = {}; // <- here
obj._leaflet_id = obj._leaflet_id || ++lastId;
return obj._leaflet_id;
}
I created PR for Leaflet lib. https://github.com/Leaflet/Leaflet/pull/6381
This issue is now fixed in v2.2.0. Thanks for reporting.
It is much better now! One thing I want to suggest:
// Deflate.js line 53
if (toProps.data && toProps.data.features && toProps.data.features.length > 0)
Leaflet.geoJSON(toProps.data, toProps).addTo(this.leafletElement);
because when we try add empty FeatureCollection then Leaflet.Deflate thow error.
I get
Cannot read property 'layerContainer' of undefined
.I belive here is the problem. Shouldn't
layerContainer
come fromcontext
?