So, I have a number of items clustered in OpenLayers.
I’m using a strategy that clusters the items based on their attributes.
I change an item’s attribute.
How do I get the clustering strategy to recalculate the cluster?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Okay, so it turns out that this feature is not available in OpenLayers as of 2.11RC1. Therefore, I have implemented it as a shadow of the Cluster class myself. The code is also available as a patch in the OpenLayers Trac.
The code at the end of this answer can be dropped directly into a javascript file and will override the existing OpenLayers
OpenLayers.Strategy.Clusterclass. It adds a methodreclusterwhich, when called, will cause the strategy to recalculate its clustering. Since we are altering theClusterbase class, any derived class should appropriately inherit thereclustermethod.An example of how to use this would be:
The code for the replacement class is: