rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
805 stars 509 forks source link

Tiles completely disappear with fitBounds(). #541

Open jamesdalg opened 6 years ago

jamesdalg commented 6 years ago
library(leaflet)
library(mapview)
#this doesn't work-- tiles disappear
bounds <- c(1, 1, 14400, 14400)
leaflet(options = leafletOptions(
    crs = leafletCRS(crsClass = "L.CRS.Simple"),
    minZoom = 0,
    maxZoom = 8)) %>% addTiles() %>% fitBounds(bounds[1],bounds[2],bounds[3],bounds[4]) %>% addMouseCoordinates()
#this works-- tiles are visible.
leaflet(options = leafletOptions(
    crs = leafletCRS(crsClass = "L.CRS.Simple"),
    minZoom = 0,
    maxZoom = 8)) %>% addTiles() %>% addMouseCoordinates()

#this doesn't work, tiles disappear.
leaflet(options = leafletOptions(
    crs = leafletCRS(crsClass = "L.CRS.Simple"),
    minZoom = 0,
    maxZoom = 8)) %>% addTiles() %>% addMouseCoordinates()
#this works, but CRS simple really is necessary for my application. A round world really wouldn't make sense, but it's for a viewing large images, like many leaflet plugins (https://leafletjs.com/plugins.html#non-map-base-layers).

leaflet(options = leafletOptions(
    crs = leafletCRS(crsClass = "L.CRS.Simple"),
    minZoom = 0,
    maxZoom = 8)) %>% addTiles() %>% fitBounds(bounds[1],bounds[2],bounds[3],bounds[4]) %>% addMouseCoordinates()
tim-salabim commented 6 years ago

see also this https://github.com/rstudio/leaflet/issues/371 to my knowledge, this is still not resolved

bhaskarvk commented 6 years ago

https://rstudio.github.io/leaflet/projections.html clearly explains that your tile server needs to support the projection you're using. OSM tiles work only with EPSG 3857 aka spherical mercator projection, so no wonder they don't work with L.CRS.Simple. L.CRS.Simple is typically ised when you have a non georeferenced image as your base layer.

jamesdalg commented 6 years ago

https://leafletjs.com/plugins.html#non-map-base-layers clearly explains ways to use deepzoom and zoomify. It's in regular leaflet, but doesn't work in this implementation.

bhaskarvk commented 6 years ago

You are confusing 2 use cases. Your issue is about addTiles() which uses OSM tiles not working with L.CRS.Simple and as I explained it simply won't regardless of the plugins option. Now as to support other base layers such as image files like the link you provided, support for those plugins will need to be added.