Reputation:
I am new to JavaScript and Leaflet.
I am able to grab my map and pan indefinitely left or right... like I'm spinning the globe a bunch of times. When I do this, the Longitude values just keep adding. For instance, I just scrolled the map for a while and now the longitude for the place I clicked is (-3047.69531). Latitude works as it should.
Is there a way to make it so that you cannot keep scrolling the basemap indefinitely. Like, only be able to pan for the length of the map and then that is all?
I'm open to suggestions.
Upvotes: 4
Views: 2008
Reputation: 53280
Welcome to SO!
Sounds like you would be interested in those Map options:
maxBounds
: When this option is set, the map restricts the view to the given geographical bounds, bouncing the user back if the user tries to pan outside the view.
worldCopyJump
: With this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible.
Upvotes: 5