Reputation: 36028
I have create a marker, and I have to update it postition.
So I use the moveTo
method:
marker.moveTo(marker.map.getPixelFromLonLat(lonlat));
Once you move the map, the marker will be located at the wrong place, why?
Upvotes: 1
Views: 355
Reputation: 36028
I got the solution through the openlayer maillist:
Instead of using :
marker.moveTo(marker.map.getPixelFromLonLat(lonlat));
You should use:
marker.moveTo(marker.map.getLayerPxFromViewPortPx(marker.map.getPixelFromLonLat(lonlat)));
Upvotes: 2