我正在尝试使用here描述的属性聚类。我复制了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);
当我运行我的页面时,只有标签可见(没有圆圈),但在放大和缩小时,没有任何功能被聚集。我的代码中缺少什么?
答案 0 :(得分:1)
你应该添加" pointRadius"属性到StyleMap,因为聚类绘制点而不是多边形要素。