Implement clustering statistics display based on openlayers and openlayers Clustering

Source: Internet
Author: User

Implement clustering statistics display based on openlayers and openlayers Clustering

Overview:

In the previous blog, we talked about how to implement clustering statistics display based on Arcgis for js and how to implement clustering statistics based on openlayers. The address of the blog post on Arcgis for js clustering statistics is:

Http://blog.csdn.net/gisshixisheng/article/details/40867989


Effect:


Key points:



Implementation Code:

1. Data Format


2. Set the display style

            var style = new OpenLayers.Style({                fillColor: "#ffcc66",                strokeColor: "#ff9933",                strokeWidth: 2,                label: "${count}",                fontColor: "#333333",                fontFamily: "sans-serif",                fontWeight: "bold"            }, {                rules: [                    new OpenLayers.Rule({                        minScaleDenominator: 100000000,                        symbolizer: {                            pointRadius: 7,                            fontSize: "9px"                        }                    }),                    new OpenLayers.Rule({                        maxScaleDenominator: 100000000,                        minScaleDenominator: 50000000,                        symbolizer: {                            pointRadius: 10,                            fontSize: "11px"                        }                    }),                    new OpenLayers.Rule({                        maxScaleDenominator: 50000000,                        symbolizer: {                            pointRadius: 13,                            fontSize: "13px"                        }                    })                ]            });

3. Add a vector Layer

            var features = new Array();            for (var i=0; i<data.length; i++) {                features[i] = new OpenLayers.Feature.Vector(                        new OpenLayers.Geometry.Point(data[i].x, data[i].y),                        {                            count:data[i].count,                            name:data[i].name                        }                );            }            var clusterLayer = new OpenLayers.Layer.Vector("Points", {                styleMap: new OpenLayers.StyleMap(style)            });            clusterLayer.addFeatures(features);            map1.addLayer(clusterLayer);


Complete program code;

<! DOCTYPE html> 




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.