leaflet map: remove road layer

邮差的信 提交于 2021-01-01 04:52:53

问题


I want to remove roads from my leaflet map in R. Is there a way to remove layers we want such as roads, lakes, state boundaries, etc.?

Sample code:

library(leaflet)
library(plot3D)
top = 45      # north lat
left = -110   # west long
right = -90   # east long
bottom =  32  # south lat

longitudes= seq(left,right, length.out = 3)
latitude=seq(bottom,top,length.out = 5)

 latlons_mesh=mesh(longitudes,latitude)

 longitude=as.vector(latlons_mesh$x)
 latitude=as.vector(latlons_mesh$y)

 mydata=data.frame(longitude=longitude,
                  latitude=latitude)

 leaflet(mydata)%>%fitBounds(right,bottom,left,top)%>%
    addTiles()%>%
    addMarkers()


回答1:


The roads and other features are part of the base tile, or you can call it 'background'.

By default the tiles are OSM's, but you can change with the addTProviderTiles() function, giving as argument one of the provider listed here.

For example a provider withour roads or boundaries is Esri.WorldShadedRelief:

leaflet(mydata) %>%
    fitBounds(right,bottom,left,top)%>%
    addProviderTiles('Esri.WorldShadedRelief') %>%
    addMarkers()


来源:https://stackoverflow.com/questions/42354903/leaflet-map-remove-road-layer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!