如何將矢量要素從地圖上的一個位置移動到另一個位置?在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