我一直在关注这个教程,但由于某种原因,我似乎无法将这些自治市镇的多边形显示在传单中。如果我做
plot(boroughs)
一切正常,您可以清楚地看到shapefile已加载并可以使用。尽管如此,使用下面的代码它不起作用。为了让这些形状显示在我的传单地图上,我缺少什么?
#load libraries
library(leaflet)
library(rgdal)
#available at http://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/nybb_15d.zip
boroughs <-readOGR("C:/Users/580048/Documents/nybb_15b/nybb.shp","nybb")
leaflet(boroughs) %>%
addProviderTiles("CartoDB.DarkMatterNoLabels",
options= providerTileOptions(opacity = 0.99)) %>%
addPolygons(
stroke = FALSE,
smoothFactor = 0.5) %>%
fitBounds(-73.9, 40.7, -73.7, 40.9)