OpenStreetMap doesn't display in RStudio (with

2019-03-06 05:01发布

问题:

I am using code from here

library(leaflet)

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

A point appears in the middle of the screen, but no map. Then I found package to download, i.e. osmar, and included that, i.e.

library(osmar)

And map is still not displaying. How to fix?

Update

I am able to access openstreetmap.com on my web browser. Javascript is enabled. Some places they mentioned use setView to display openstreetmap but when I try, the screen is now blank, no pop-up pointer

library(osmar)
library(leaflet)

m <- leaflet() %>%
  addTiles() %>%  
  setView(174.768, lat=-36.852, zoom=18)
m

回答1:

I had the same issue, found this and worked very well for me:

%>% addProviderTiles(providers$OpenStreetMap) %>% 

found it here: https://gis.stackexchange.com/questions/187926/leaflet-output-is-grey