Moving left and right

I can not get the map to have like a boundary. You are able to continue moving left and right forever

What map viewer or editor are you using and what problem are you trying to solve?


I am using leaflet which uses openstreetmap and everything works but if you grab the map and move it left and right then it will go on forever but I have pinpoints on the map and it will not show them after you move so far out

1 Like

Which URL, on which website? Are you coding your own stuff?

This is the URL that I am using and it carries you to the page. Yes I am coding my own stuff

1 Like

Ok, so your’re coding your own stuff using Leaflet. Something similar to my PTNA-Page?


  • you click the left mouse and move the map to the left/right and then you release the mouse button
    • the map stops where you released the button?
    • the map keeps on moving around the world?
1 Like

Try downloading and modifying Change the Leaflet version, and the tile URL, and see how it behaves.

That is exactly right!! But I don’t want it to keep moving, I want to make a boundary so it can’t go past a certain spot

What is exactly right, the first or second behaviour?

Anyway, if your want some limits, you have to check the Leaflet documentation and extend your code. Leaflet needs to know how far to the left, right, bottom and top your users are allowed to move.

1 Like

Both behaviors are correct. When you click and drag it stops when you let off the mouse but also it will move as many times as you click and drag. It has no stopping point to where you cant drag anymore

Understood, your initial description of the problem was not clear to me, so I was asking. I thought you had problems with

As always: ask DuckDuckGo “leaflet set boundary”


I apologize for the confusion! Thanks for your help anyway!

1 Like

You’re welcome.

The second behaviour was more like … release the mouse button but the map does not stop moving.

No, that isn’t an issue its just that you can continue clicking and dragging until you get ready to stop but I want it where you can only drag a certain distance and then it won’t let you drag anymore

1 Like