commenthol / leaflet-rastercoords

Leaflet plugin for plain image map projection to display large images using tiles generated with gdal2tiles-leaflet
https://commenthol.github.io/leaflet-rastercoords
MIT License
120 stars 23 forks source link

Negative north bounds not working #7

Closed rannooo closed 2 years ago

rannooo commented 3 years ago

Hi and thanks for the great plugin!

I'm trying to use L.RasterCoords and set bounds that are 20% larger than the image.

map.setMaxBounds(new L.LatLngBounds(southWest, northEast).pad(0.2))

Using this, max bounds are respected on the east, south and west side, but not on the north side.

Here is a skimmed down version of this repo's example, which demonstrates this issue: (please zoom in so deep that grey background is not visible, then try panning to west (20% allowed) and then north (0% allowed)

https://codepen.io/rannooo/pen/wvWaNXg

I have also tried to set bounds manually, without the .pad() function, but had same results. It seems that setting negative bound coordinates to the north direction fails, but negative bounds to the west side work as intended..

takvol commented 2 years ago

It's a bit late, but if someone needs it you can try to set crs: L.CRS.Simple in the map. https://codepen.io/Takvol/pen/JjyEVjY

var map = L.map('map', {
    crs: L.CRS.Simple,
    ...
})
commenthol commented 2 years ago

Proposed changes are part of v1.0.4 Credits go to @takvol :clap: