如何将矢量要素从地图上的一个位置移动到另一个位置?在OpenLayers中将功能从一个位置移动到另一个位置3
我有一个在(0.0,0.0)生成一个图标如下:
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point([0.0,0.0])
});
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 0.75,
src: 'marker-icon.png'
}))
});
iconFeature.setStyle(iconStyle);
这工作得很好,但我怎么现在它移动到另一个位置?
我已经试过:
iconFeature.move(x,y);
我也试过
iconFeature.geometry.move(x,y);
后者说iconFeature.geometry是不确定的,第一个说icon.move()不是一个函数。
先前在SO上的答案暗示了这些解决方案,但它们似乎并不适合我。
解决方案发布,它可以完成,只是没有很多文件。 – 2014-11-01 10:48:40