我正在尝试在 R 中创建加拿大的交互式离线地图经过一番搜索后,RgoogleMaps 和 Leaflet 似乎是最好的选择。我在这里遵循了代码:R Leaflet Offline Map Tiles Not Loading
这是我的代码:
setwd("C:/Users/user/Documents")
library(servr)
library(RgoogleMaps)
# Load the tiles in working_folder/mapTiles/OSM/
for (zoom in 2:13)
GetMapTiles("Canada", zoom = zoom,
nTiles = round(c(20,20)/(17-zoom)))
# Start serving working folder on port 8000 in demon mode
deamon_id <- servr::httd(port = 8000, daemon = TRUE)
# Plot with leaflet
library(leaflet)
m = leaflet() %>%
addTiles( urlTemplate =
"http:/localhost:8000/mapTiles/OMS/{z}_{x}_{y}.png")
m = m %>% leaflet::setView(-76, 45 , zoom = 5)
m = m %>% leaflet::addMarkers(-76, 45 )
m
# Stop serving
servr::daemon_stop(deamon_id)
悬停,当我放大/缩小地图时,灰色瓷砖出现在以前没有的地方:
但,
关于出了什么问题的任何想法?谢谢!