3

I have a basic Leaflet map where I need to draw several markers and lines on. How do I prevent the map from panning to the last drawn object?

I've read about setting autopan : False for popups from here.

Can the autopan : false option work for leaflet markers?

3
  • 2
    Are you saying that you digitize a new element, and then the map automatically zooms to that element? And that you want to avoid that? If your code is not too long you might also want to share it, so it would be easier to solve the issue. Commented Feb 3, 2015 at 13:12
  • It's a pretty basic problem. I'll see if I can put together an example
    – FredFury
    Commented Feb 3, 2015 at 13:19
  • That'd be nice. Just not entirely sure if I understood the question, hence I was asking. Commented Feb 3, 2015 at 13:26

1 Answer 1

1

It appears that you can.

var markerWithoutPan = new L.Marker([0, -10], {
    draggable: true,
    autoPan: false,
    title: 'NoPan'
});

Source

Leaflet docs for Markers

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.