我有代码在地图上显示点如下:
m <- leaflet(mdt) %>%
addTiles('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png', attribution='Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://www.openstreetmap.org copyright">OpenStreetMap</a>') m %>%
addCircles(~mdt$Pickup_longitude, ~mdt$Pickup_latitude, popup=mdt$Trip_type, weight = 3, radius=40, color="#ffa500", stroke = TRUE, fillOpacity = 0.8) %>%
addCircles(~mdt$Dropoff_longitude, ~mdt$Dropoff_latitude, popup=mdt$Trip_type, weight = 3, radius=40, color="#9dea3f", stroke = TRUE, fillOpacity = 0.8 ) %>%
addLegend("bottomright", colors= "#ffa500", labels="NYC'", title="Pickup & Drop off Locations")
我的地图外观如下:
如何更改地图类型,我想使用明确颜色的开放街道地图,如下所示:
我想只更改地图类型。什么是最简单的方法。
答案 0 :(得分:0)
对于那些可能出现同样问题的人来说,这是答案。
m <- leaflet(mdt) %>% addTiles(options = providerTileOptions(opacity = .5)) m %>% addCircles(~mdt$Pickup_longitude, ~mdt$Pickup_latitude, popup=mdt$Trip_type, weight = 3, radius=40, color="#8B008B", stroke = TRUE, fillOpacity = 0.8) %>% addCircles(~mdt$Dropoff_longitude, ~mdt$Dropoff_latitude, popup=mdt$Trip_type, weight = 3, radius=40,
color="#00FF00", stroke = TRUE, fillOpacity = 0.8 )