我想在开放图层中向矢量层添加一个点,但是当我使用策略集群时,无法添加点。
我编写了显示这种情况的这段代码(http://jsfiddle.net/xd2n9qk7/2/)。如我们所见,当我单击添加一个点时,所有其他点都消失了,只有一个保留了。
map = new OpenLayers.Map('map');
var base = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {
layers: 'basic'
});
clusters = new OpenLayers.Layer.Vector("Clusters", {
strategies: [new OpenLayers.Strategy.Cluster()],
});
point = new OpenLayers.Control.DrawFeature(clusters, OpenLayers.Handler.Point, {
eventListeners: {
"featureadded": function(){console.log(clusters.features)}
}
});
map.addLayers([base, clusters]);
map.addControl(point)
point.activate()
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
clusters.addFeatures(features);
我希望该点将添加到群集中,并且该图层会重绘自身。