سؤال

In the Leaflet JS library, it says:

Pans the map to a given center. Makes an animated pan if new center is not more than one screen away from the current one.

Probably a longshot, but does anyone know if there's a way to force panning more than one screen? I don't mind if there's greyed out tiles during panning.

Source: http://leaflet.cloudmade.com/reference.html

هل كانت مفيدة؟

المحلول

I found there's a workaround for this:

var offset = map._getNewTopLeftPoint(latlng).subtract(map._getTopLeftPoint();
map.panBy(offset);

The developers are planning a more direct API in the future.

نصائح أخرى

To achieve panning for more than one screen you can use setView with animate set to true.

map.setView([latitude, longitude], zoom, {animate: true, duration: 1});

I guess it would also be good to calculate the duration depending on the distance to the next point and the zoom level, so it will always be smooth and not too fast or slow.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top