Problem with maximum panning

12 views
Skip to first unread message

zamehan

unread,
May 31, 2018, 12:01:01 PM5/31/18
to Leaflet
Hello,

I want the restrict the panning of a world map horizontally and not vertically (longitude but not latitude) because this map will display pictures when I click on them and I cant see well the image when i restrict the panning horizontally AND vertically. 

I try to play with maxBounds and setMaxbounds. The normal maxBounds (to view the world map) is :
maxBounds: [[-85, -180.0],[85, 180.0]],

When i try to put the latitude to [[-150, -180.0],[150, 180.0]], the vertical panning is still restricted. Can somebody help please? Thank you. 

Peter Thomson

unread,
May 31, 2018, 12:11:31 PM5/31/18
to leafl...@googlegroups.com
If the intention is to display images with pan and zoom you need to use a different coordinate system.
For images we use a different coordinate system to normal maps. We use crsL.CRS.Simple and we use the pixel sizes of our image as our coordinates
Have a look at a tutorial:


--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Peter Thomson

unread,
May 31, 2018, 1:04:05 PM5/31/18
to leafl...@googlegroups.com
When you are working with a world map I don't think you can go outside 85, as this is a projection of a sphere.
Could you offset the point at which your images appear to keep them within the viewable space?


On Thu, May 31, 2018 at 5:22 PM, Martin Jozan <marti...@gmail.com> wrote:
The map I am referring to is a real world map, not a picture. But when I click on certain locations, it makes small images appear. Because of the maximum vertical panning, the images are cropped. 

zamehan

unread,
Jun 1, 2018, 3:24:26 AM6/1/18
to Leaflet
If one doesn't put maxBounds or setMaxBounds, it is possible to pan outside 85 in latitude. 
Reply all
Reply to author
Forward
0 new messages