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

If cluster is spiderfied and the cluster layer get its markers updated, the position on the markers is incorrect #54

Closed
grantlucas opened this issue Sep 5, 2012 · 3 comments

Comments

@grantlucas
Copy link

This may or may not be related to #53

I have a set of filters on my map to limit which markers are shown.

If I limit the markers to only one marker is showing which would otherwise be clustered, the position is accurate as seen here. If I have both markers in the cluster, spiderfy, and then update the filters so that only one marker is left, the location of that marker is the position of where it spiderfied to instead of the location original location as seen here. The lines still showing is what's referenced in #53 and why i think they might be related.

When my filters change, I'm

  • Removing the cluster layer from the map
  • Re-initializing the cluster layer with new L.MarkerClusterGroup();
  • Loop through markers which should remain on the map and add their layers to the cluster layer
  • Once done, add the marker cluster layer to the map again

Below is the code

//Clear the current marker cluster group
me.map.removeLayer(me.markerCluster);
me.markerCluster = new L.MarkerClusterGroup();

//Go through items and update which are on the map
for(var id in me.markers)
{   
    //Add it to the layer group
    me.markerCluster.addLayer(me.markers[id]);
}   

me.map.addLayer(me.markerCluster);

Let me know if anymore information is needed!

@danzel
Copy link
Member

danzel commented Sep 6, 2012

About to look at this.
My thought is that the spiderfier is updating the latlng of the marker when spiderfying (needed so that if we add a popup it is in the right place) but the original position is not being restored when the MarkerClusterGroup is removed from the map.

danzel added a commit that referenced this issue Sep 6, 2012
danzel added a commit that referenced this issue Sep 6, 2012
@danzel
Copy link
Member

danzel commented Sep 6, 2012

This should be fixed, please reopen if not!

@danzel danzel closed this as completed Sep 6, 2012
@grantlucas
Copy link
Author

Excellent. I can confirm that both #53 and #54 are resolved. Thanks for the prompt fix!

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