从地图上删除国家和城市名称

时间:2018-08-09 12:37:44

标签: r ggmap

我使用ggmap包,通过

生成地图
map <- get_map(location = c(10, 51), zoom = 6, maptype = "toner-lite", 
               scale = 1, color = "bw")
ggmap(map)

是否可以删除国家和城市名称,以及除寄宿家庭以外的所有寄宿生?

2 个答案:

答案 0 :(得分:0)

如果您具有启用了结算功能的Google Maps API密钥,则可以尝试:

Read more on lambda expressions on the MSDN

代码

map <- get_googlemap(c(10, 51), zoom = 6, scale = 1, style = s)
ggmap(map)

数据

s <- "element:geometry%7Ccolor:0xf5f5f5&style=element:labels%7Cvisibility:off&style=element:labels.icon%7Cvisibility:off&style=element:labels.text.fill%7Ccolor:0x616161&style=element:labels.text.stroke%7Ccolor:0xf5f5f5&style=feature:administrative%7Celement:geometry%7Cvisibility:off&style=feature:administrative.country%7Celement:geometry.stroke%7Ccolor:0x000000%7Cvisibility:on&style=feature:administrative.land_parcel%7Cvisibility:off&style=feature:administrative.land_parcel%7Celement:labels.text.fill%7Ccolor:0xbdbdbd&style=feature:administrative.neighborhood%7Cvisibility:off&style=feature:poi%7Cvisibility:off&style=feature:poi%7Celement:geometry%7Ccolor:0xeeeeee&style=feature:poi%7Celement:labels.text.fill%7Ccolor:0x757575&style=feature:poi.park%7Celement:geometry%7Ccolor:0xe5e5e5&style=feature:poi.park%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&style=feature:road%7Cvisibility:off&style=feature:road%7Celement:geometry%7Ccolor:0xffffff&style=feature:road%7Celement:labels.icon%7Cvisibility:off&style=feature:road.arterial%7Celement:labels.text.fill%7Ccolor:0x757575&style=feature:road.highway%7Celement:geometry%7Ccolor:0xdadada&style=feature:road.highway%7Celement:labels.text.fill%7Ccolor:0x616161&style=feature:road.local%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&style=feature:transit%7Cvisibility:off&style=feature:transit.line%7Celement:geometry%7Ccolor:0xe5e5e5&style=feature:transit.station%7Celement:geometry%7Ccolor:0xeeeeee&style=feature:water%7Celement:geometry%7Ccolor:0xc9c9c9&style=feature:water%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&size=480x360"
# Generated on https://mapstyle.withgoogle.com/

答案 1 :(得分:0)

您可以通过更改 terrain-background 地图的不透明度并更改 ggplot 中的一些主题元素来合理地接近。

map <- get_map(location = c(10, 51), zoom = 6, maptype = "toner-background", 
               scale = 1, color = "bw")

# change opacity of basemap
mapatt <- attributes(map)
map_transparent <- matrix(adjustcolor(map, alpha.f = 0.2), nrow = nrow(map))
attributes(map_transparent) <- mapatt

ggmap(map_transparent) + 
  theme(panel.grid = element_blank(), panel.background = element_rect(fill = 'white'))

enter image description here

相关问题