hguser
hguser

Reputation: 36028

openlayer markers located at the wrong place

I have create a marker, and I have to update it postition.

So I use the moveTo method:

marker.moveTo(marker.map.getPixelFromLonLat(lonlat));

Live Exmaple:

Once you move the map, the marker will be located at the wrong place, why?

Upvotes: 1

Views: 355

Answers (1)

hguser
hguser

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

Related Questions