CloudMade/Leaflet — Issue #537: viewreset called before pan animation completes yielding inaccurate latLngToLayerPoint result
Author: krosaen
Created: 2012-02-24 22:24:56+00:00
State: open

If one relies on the 'viewreset' callback to know when to update custom overlay's position (e.g by converting from a lat lon to map position map.latLngToLayerPoint(latlng).round() and then using L.DomUtil.setPosition(element, pos)), it works in most cases, including zooming in and out, and whenever the map is redrawn.

However, in some cases when the map is panned using 'map.setView(latlng)', the viewreset callback is fired before the map finishes panning, resulting in views being placed improperly.

To reproduce, visit:

http://www.realtimefarms.com/

in the 'move the map to' box, type 'Grand Rapids' and then 'Chicago'. Notice the pins sitting in the middle of Lake Michigan.

Note that these pins are being rendered using images as an overlay, not using the Marker objects, though from the source code it appears Marker is implemented the same way, using a 'viewreset' callback to update its position, so I would guess this example would also reproduce if Marker objects were used.