[英]Openlayer 2.x clustering
我正在尝试使用此处描述的属性聚类。 我已经复制了OpenLayers.Strategy.AttributeCluster =...
片段。 这是我的代码:
styleMap = new OpenLayers.StyleMap({
label: "${labelText}",
fontColor: "blue",
fontSize: "12px",
fontFamily: "Courier New, monospace",
fontWeight: "bold",
labelAlign: "lc",
labelXOffset: "14",
labelYOffset: "0",
labelOutlineColor: "white",
labelOutlineWidth: 3,
//fillColor: "#ee9900",
fillColor: "${fillColor}",
fillOpacity: 0.3,
stroke: false
});
strategies.push(new OpenLayers.Strategy.AttributeCluster({
attribute: 'obs'
}));
var vectorLayer = new OpenLayers.Layer.Vector("Overlay", {
styleMap: styleMap,
strategies: strategies
});
map.addLayer(vectorLayer);
我通过以下方式创建功能:
var circle = new OpenLayers.Geometry.Polygon.createRegularPolygon(
new OpenLayers.Geometry.Point( dataArr[i][2],dataArr[i][1]).transform(epsg4326, projectTo), 100, 20, 0);
var feature = new OpenLayers.Feature.Vector(circle, {labelText: dataArr[i][0], all: dataArr[i][5],ami: dataArr[i][6],obs: dataArr[i][3], fillColor: areaColors[dataArr[i][3]]});
然后将要素添加到图层:
vectorLayer.addFeatures(features);
当我运行我的页面时,只有标签可见(没有圆圈),但是在放大和缩小时没有任何功能聚集。 我的代码中缺少什么?
您应该在样式地图中添加“ pointRadius”属性,因为聚类绘制的是点而不是多边形要素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.