2

According to the Leaflet docs the marker's autoPan option works like this:

Set it to true if you want the map to do panning animation when marker hits the edges.

What does 'the marker hits the edges' mean?

When I set the option to true and add a new marker right on the edge or outside of the current view, the map does not automatically move.

1 Answer 1

2

The autoPan option of L.Marker dates back to https://github.com/Leaflet/Leaflet/pull/5651 - as you would be able to see, it implements https://github.com/Leaflet/Leaflet/issues/3572 , which is about automatically panning the map when dragging a draggable marker near the edge of the map viewport.

3
  • Makes sense. So this should work if I set both draggable and autoPan to true? As in: var m = L.marker([0, 0], {draggable: true, autoPan: true}); Commented Aug 20, 2018 at 21:23
  • Yeah, that's the idea. Commented Aug 21, 2018 at 7:07
  • It works now! Was using 1.2 and now updated to 1.3.3. Nice effect :-) Commented Aug 21, 2018 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.