OpenLayers Cluster Recalculate

后端 未结 2 1968
清酒与你
清酒与你 2021-01-01 01:36

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.

2条回答
  •  礼貌的吻别
    2021-01-01 01:42

    OpenLayers.Strategy.Cluster.cluster method recalculate only if it is a zoomechanged event or clusters object does not exist. remove the clusters object and call cluster on Cluster object.

    var clustering=new OpenLayers.Strategy.Cluster()
    var vectorlayer = new OpenLayers.Layer.Vector('Vectorlayer', {
                                                  strategies: [clustering]
    });
    
    //ADD_LOTS_OF_FEATURES_TO_VECTOR_LAYER
    
    clustering.distance=value;
    //cluster() recalculate only if it is a zoomechanged event or clusters object does not exist.
    clustering.clusters = null; //remove cluster object so that it calculates again.
    clustering.cluster();
    

提交回复
热议问题