【发布时间】:2023-03-15 08:20:01
【问题描述】:
如何将矢量特征从地图上的一个位置移动到另一个位置?
我有以下在 (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 的先前答案提出了这些解决方案,但它们似乎对我不起作用。
【问题讨论】: