OpenLayers, nice marker clustering

前端 未结 6 1195
刺人心
刺人心 2020-12-12 18:50

Do you know how to have a nice clustering in OpenLayers such as this google example ?

6条回答
  •  死守一世寂寞
    2020-12-12 19:01

    Here is the JSfiddle for clustering based on custom attributes added to the layers. I struggled a bit with this so putting it here; Also shows creating a summary pie graph image when zoomed out with the clustered data http://jsfiddle.net/alexcpn/518p59k4/

    Also created a small openlayer tutorial to explain this OpenLayers Advanced Clustering

        var getClusterCount = function (feature) {
    
        var clustercount = {};
        var planningcount = 0;
        var onaircount = 0;
        var inerrorcount = 0;
    
        for (var i = 0; i < feature.cluster.length; i++) {
    
            if (feature.cluster[i].attributes.cluster) {
            //THE MOST IMPORTANT LINE IS THE ONE BELOW, While clustering open layers removes the orginial feature layer with its own. So to get the attributes of the feature you have added add it to the openlayer created feature layer
                feature.attributes.cluster = feature.cluster[i].attributes.cluster;
                switch (feature.cluster[i].attributes.cluster) {
    
     ......
        return clustercount;
    };
    

提交回复
热议问题