Open virux84 opened 8 years ago
Are you creating a Shiny app? Or a stand-alone HTML file?
I tried with both of them, with no succes Il 12/ott/2015 11:23 PM, "Joe Cheng" notifications@github.com ha scritto:
Are you creating a Shiny app? Or a stand-alone HTML file?
— Reply to this email directly or view it on GitHub https://github.com/rstudio/leaflet/issues/194#issuecomment-147526408.
I successfully use local tiles (they are not download but created by me, the structure is something like: "map/tiles/{z}/{x}/{y}.png" ) inside a Shiny app.
I just use:
m <- leaflet()
m <- addTiles(m,urlTemplate = "map/tiles/{z}/{x}/{y}.png")
and the directory map/ is inside www/ I was not able to use it outside a Shiny app.
Please could you explain me step by step how to set up my shiny app? Also the complete path file? Thank you very much Il 13/ott/2015 02:56 PM, "Gherardo Varando" notifications@github.com ha scritto:
I successfully use local tiles (they are not download but created by me, the structure is something like: "map/tiles/{z}/{x}/{y}.png" ) inside a Shiny app. I just use:
m <- leaflet() m <- addTiles(m,urlTemplate = "map/tiles/{z}/{x}/{y}.png")
and the directory map/ is inside www/ I was not able to use it outside a Shiny app.
— Reply to this email directly or view it on GitHub https://github.com/rstudio/leaflet/issues/194#issuecomment-147706702.
I wrote a simple app to show it https://github.com/gherardovarando/examples I created a map from a wikipedia image (https://en.wikipedia.org/wiki/History_of_Boston#/media/File:Boston_area_colonial_map.jpg)
The map is a bit distorted because the method I use to produce the map directory is supposed to work with square images, so it fit the initial image to a square.
Example on shinyapps: https://gherardo.shinyapps.io/exampleLocalTiles
thank you very much. It works great :-)
Has someone an idea why it's not working outside a shiny app?
the problem I think is that, if you are not in a shiny app there is no server able to answer the request of map's tiles. I succeed using local tiles in this way:
1) go to the directory where you have the tiles and start for example an HTTP server with python's SimpleHttpServer :
in a terminal: python -m SimpleHTTPServer 8000
2) in R:
tilesUrl <- "http://localhost:8000/tiles/{z}/{x}/{y}.png"
leaflet() %>% addTiles(urlTemplate = tilesUrl, option=list(continuousWorld=TRUE, tileSize="256",minZoom="0",maxZoom="5") )
obviously the tilesUrl
depends on the structure of your local tiles.
In the terminal you can actually see the server answering the tiles requests.
@gherardovarando Thanks for the example app, it was exactly what I wanted to do However the leaflet appears grey as soon as I subset your tiles by mines (which are extracted from a raster) But it works when I host them on an external server: any idea why it fails in local?
[edit] Nevermind, it works perfectly. I just forget to set the "tms" option to TRUE within the addTiles:
addTiles(urlTemplate = "tiles_test/{z}/{x}/{y}.png", option = tileOptions(tms = TRUE))
Hi, I'm trying to develop a R app that use the leaflet package but with local downloaded tiles.
Using this code:
tilesDir <- 'file:///c:/MapQuest/{z}/{x}/{y}.png' leaflet() %>% addTiles(urlTemplate =tilesDir)
But it not shows anything. How Can I use local tiles? Thank you