http:/localhost:8000/mapTiles/OSM/{z}_{x}_{y}.png not working - SHINY R

Viewed 336

I'm working on a project with a shiny app running offline because I have to work in sewer systems. I managed to run my app with a batch file (converted in a .exe file since it looks more professional)

I did some test and I have encountered a problem with Leaflet and the tiles. It doesn't work offline. I tried many things to make it works offline :

  • Loading the tiles in my working folder:
    setwd("C:/TestApp/data_hydrepat/tiles_hydrepat")
    center=getGeoCode("Paris") 
    for (zoom in 10:16) 
    {GetMapTiles(
    center, 
    zoom = zoom,
    nTiles = round(c(20,20)/(17-zoom)),
    tileDir="C:/TestApp/data_hydrepat/tiles_hydrepat/mapTiles/OSM/",
    urlBase= "http://a.tile.openstreetmap.org/",
    type = "osm") }
    

========================================================================

  • Now that I have multiple png in the folder, I'm starting a serving working folder on port 8000 in demon mode.

    deamon_id <- servr::httd(port = 8000, daemon = TRUE)

========================================================================

  • I'm trying to plot everything with those lines:

    tilesUrl <-"http:/localhost:8000/mapTiles/OSM/{z}_{x}_{y}.png" 
    m =leaflet::leaflet() %>%    
    addTiles( urlTemplate = "tilesUrl",option =
    tileOptions(tms = TRUE)) 
    m = m %>%
    leaflet::setView(2.351462,48.856697,zoom = 10) m = m %>%
    leaflet::addMarkers(2.351462,48.856697) 
    m
    servr::daemon_stop(which = daemon_list())
    

========================================================================

It doesnt work (only showing the marker at the right place but with a grey background, you can try to write the below code with the default tiles

```
m = leaflet::leaflet() %>%    addTiles() m = m %>% leaflet::setView(2.351462,48.856697,zoom = 10) m = m %>%
leaflet::addMarkers(2.351462,48.856697) 
m
```

========================================================================

Then I thought the problem was coming from the serving working folder. So I tried to launch only one png and it was working. So I think the problem is coming from: {z}_{x}_{y}.png But I'm not really sure. Does this line work on R Leaflet? What could be the problem? I looked everywhere on google, couldn't find a solution. I'm trying to add every png as a unique tiles with this command. https://help.openstreetmap.org/questions/13645/could-anyone-explain-this-to-me-leaflet Here is the only source I could find explaining the {z}_{x}_{y}.png

You can check for more details about what i try to achieve https://rdrr.io/rforge/RgoogleMaps/man/GetMapTiles.html

Can someone help me please ?

Best Regards, Anthony

0 Answers
Related