2
votes

Background: I am currently drawing a leaflet map using the following code:

library(leaflet) 
leaflet()%>%
addProviderTiles("Stamen.TerrainBackground")%>%
setView(lng=-81,lat=45,zoom=6)

Problem: The problem is that it takes around 4 seconds to have the map appear. This is an undesirable feature when I integrate the map with Rshiny, given that the website appears blank until the map finally loads.

I'm wondering two things:

1) Is there an open source map that is known to load quickly compared to other maps.

2) If 1) is not possible, I have noticed that in google maps, the tiles of the map start appearing in sequence. At least like that the user is able to know that the map is loading. Is there a way of having the tiles be drawn sequentially like that?

1
Could you just use Google Maps? I have a tutorial on using it in R at hack-r.com but I'm not sure how things may be different with a leaflet map.Hack-R
You can try rbokeh(hafen.github.io/rbokeh). In my experience, it has usually been much quicker than leaflet.ytk
Thanks both for the answer. I was under the impression that leaflet was the go to library for anything map related. Is this not the case?DanRoDuq
Why not just draw a map in R? Why do you need tiles?hrbrmstr
you could experiment with the options at leaflet-extras.github.io/leaflet-providers/preview, and see which is fastest for yousckott

1 Answers

1
votes

If you mean the tiles are slow to load, that is most likely either a problem with the tile provider or a problem with your connection. Leaflet itself is usually very fast in my experience.

As far as the tile provider, I've always had good success with open street map in JS.

With R it looks like this link https://rstudio.github.io/leaflet/ has the following example using OSM:

library(leaflet)

m <- leaflet() %>%
  addTiles() %>%  # Add default OpenStreetMap map tiles
  addMarkers(lng=174.768, lat=-36.852, popup="The birthplace of R")
m  # Print the map

So calling "addTiles() %>% should use open street map as default.