How do I move a vector feature from one position on a map to another?
I have the following which generates an icon at (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);
This works fine, but how do I now move it to another location?
I've tried:
iconFeature.move(x,y);
I've also tried
iconFeature.geometry.move(x,y);
The latter says that iconFeature.geometry is undefined, the first says icon.move() is not a function.
Previous answers on SO suggest these solutions, but they don't seem to work for me.