ggmap自定义地图样式 [英] Custom map style with ggmap

查看:183
本文介绍了ggmap自定义地图样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用 https://mapstyle.withgoogle.com/自定义了供ggmap使用的样式.一个>.我的问题是如何将JSON集成到我的R代码中.

I have customized a style for use with ggmap using https://mapstyle.withgoogle.com/. My question is how to integrate the JSON into my R code.

我尝试了以下代码,但无济于事:

I tried the following code to no avail:

map <- get_googlemap(center = 'London', zoom = 15, 
                     style = c('element:labels|visibility:off', 'feature:road.local|visibility:off'))
ggmap(map)

它可以单独使用任何一种样式命令,但不能一起使用.我的代码中的错误在哪里?

It works with either of the style commands alone but not together. Where is the bug in my code?

推荐答案

我已经开发了一个软件包ggmapstyles,该软件包应有助于解决此问题:

I have developed a package ggmapstyles, which should help with this problem: https://github.com/dr-harper/ggmapstyles

该程序包使您可以从时髦的地图中选择设计,并且使用页面中的样式就像复制一样简单URL变成样式:

The package lets you select designs from Snazzy Maps, and using the style from the page is as simple as copying the URL into the style:

devtools::install_github("mikey-harper/ggmapstyles")
library(ggmapstyles)

map <- get_snazzymap(center = 'London', 
                     mapRef = "https://snazzymaps.com/style/61/blue-essence")
ggmap(map)

如果找不到喜欢的设计,则可以免费加入Snazzy Maps,并在网络浏览器中进行自己的自定义设计.

If you don't find a design you like, you can join Snazzy Maps for free and make your own custom design within the web browser.

这篇关于ggmap自定义地图样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆