Problem when viewing html generated by Leaflet

Hi, I have created an interactive map using OpenStreetMap as background tile and also include popup for all the circles as well as a color scale legend. I then go to Export->Save as Web Page to save it as a html.

However, when open up the html, the Map tile can not be loaded and seen while all the other elements are ok. Does any one knows why and how can I deliver the result so the map can be seen independent of R studio?

Many Thanks

Without your code, I guess this can solve your problem:

addTiles('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')

I hope this will help you.

If you need to deliver the leaflet map as a standalone html you sholud use saveWidget function from htmlwidgets package.

Are you sure that your Internet connection is fine?

Hi Paul, thanks for you reply. Below is the part of my code generating the map widget. OpenStreetMap is the default map tile so I did not claim it explicitly, I tried to replace the 2nd line with yours (with "%>%" to the end) but it did not work either.

m <- leaflet(f171028_sub) %>%
  addTiles() %>%  # Add default OpenStreetMap map tiles
  addCircles(lng = ~ lng, lat = ~lat, popup = ~popup, radius = 0.25, color = ~pal(disp2), opacity = 0.75) %>% 
  addLegend("bottomright", pal = pal, values = -15:15,
          title = "Ground Movement (mm)",
          opacity = 1
          )

Yes. the internet is ok. Every element shows well in Rstudio Viewer

I tried to load htmlwidets package and then try the code below but got an error message

saveWidget(m,"testing.html")
Error in system(paste(shQuote(pandoc_path), "--version"), intern = TRUE) :
'"C:/Users/zhangwei.ning/AppData/Local/Continuum/Anaconda3/Library/bin/pandoc"' not found

Maybe you can try a reinstallation of pandoc, because:

from htmlwidget

f (!pandoc_available()) {
stop("Saving a widget with selfcontained = TRUE requires pandoc. For details see:\n",
"https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md")
}

If you have not pandoc installed it should break in that stop and show you the message, perhaps pandoc installation got corrupted. So I would try the pandoc installation

@zning, could try the code below?

Here, the tile appears normally in browsers (firefox and crhome).

library(ggmap)
library(leaflet)
library(htmlwidgets)

br <- geocode("Fortaleza - Brazil")

l <- leaflet(br) %>% 
 addTiles('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png') %>% 
 addMarkers()

saveWidget(l, 'leaflet.html')

br <- geocode("Fortaleza - Brazil")
Error: Google now requires an API key.
See ?register_google for details.