Package leaflet - map doesn't show

2019-07-26 04:56发布

问题:

I got some question about the package "leaflet" which I'm using with Rstudio.

My problem is, that the basemap isn't shown. But at the bottom of the viewer is written "OpenStreeMap" and the options to zoom in and out are also shown.

Somebody knows about this problem?

library(leaflet)
m <- leaflet()
m <- addTiles(m)
m <- addMarkers(m, lng=174.768, lat=-36.852, popup="The birthplace of R")
m

The easy example is shown here: https://rstudio.github.io/leaflet/

回答1:

If you are behind a proxy try to add provider info

library(leaflet)
m <- leaflet() %>%
  addTiles(urlTemplate = "http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png", 
       attribution = '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>')
m


回答2:

I have a solution: If I click in RStudio on "Show in new Window" the map opens in the browser and there I can see it.

Maybe the map only work in the browser?



标签: r leaflet