Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clearLayers method does not remove the layers from the map #1034

Open
seerj30 opened this issue Sep 21, 2021 · 2 comments
Open

clearLayers method does not remove the layers from the map #1034

seerj30 opened this issue Sep 21, 2021 · 2 comments

Comments

@seerj30
Copy link

seerj30 commented Sep 21, 2021

I'm using "leaflet.markercluster": "^1.5.0" into an Angular app.
The marker cluster is created as follow:

markerCluster = new MarkerClusterGroup({
    spiderfyOnMaxZoom: false,
    showCoverageOnHover: false,
    disableClusteringAtZoom: this.maxZoom,
});

then is added to the map this.map.addLayer(this.markerCluster);.
Adding markers to the marker cluster works like a charm (this.markerCluster.addLayers(this.markerLayers);) but the problem appears when I'm trying to delete them because this.markerCluster.clearLayers(); does not remove the layers from the map and I have to do it manually:

this.markerLayers.forEach((x) => {
    this.map.removeLayer(x);
});

Isn't expected from clearLayers method to remove the layers also from the map?

@IvanSanchez
Copy link
Member

Can you publish a fiddle/codepen/plunkr that displays this behaviour?

And I mean "without angular", because I've already seen https://stackoverflow.com/questions/69271376/marker-cluster-clearlayers-method-does-not-remove-the-layers-from-the-map

@seerj30
Copy link
Author

seerj30 commented Sep 21, 2021

It will take a couple of hours to extract it. But I think I found something similar here: https://stackoverflow.com/questions/42862370/refresh-marker-clusters-after-geojson-layer-has-changed
#647 (comment)
It's like the marker cluster group is decoupled from the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants