我试图在R中使用函数get_map()为某个位置绘制一个简单的地图。以下是我的代码:
EG
get_map(location = "texas", zoom = 10, source = "google")
我尝试过不同的参数。我得到的错误如下:
Error in aperm.default(map, c(2, 1, 3)) :
perm' is of wrong length 3 (!= 2)
背景中究竟发生了什么?我该如何解决?我检查了所有可能的博客,似乎没有人得到这个错误。
请帮忙!
由于基本URL,会发生此错误。在CRAN version
,基本网址并不安全。从{github}使用此软件包的dev版本而不是函数运行正常。使用devtools::install_github(""dkahle/ggmap")
从github安装库
我是github的ggmap,但在这里遇到同样的问题......
> devtools::install_github("dkahle/ggmap")
Skipping install of 'ggmap' from a github remote, the SHA1 (7b696967) has not changed since last install.
Use `force = TRUE` to force installation
> library(ggmap)
Carregando pacotes exigidos: ggplot2
Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
Please cite ggmap if you use it! See citation("ggmap") for details.
> register_google(key = "MyKey")
> geocode("parque do ibirapuera")
Source : https://maps.googleapis.com/maps/api/geocode/json?address=parque+do+ibirapuera&key=xxx-mKaA7Kw
# A tibble: 1 x 2
lon lat
<dbl> <dbl>
1 -46.7 -23.6
> get_map(location = "texas", zoom = 10, source = "google")
Source : https://maps.googleapis.com/maps/api/staticmap?center=texas&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx-mKaA7Kw
Error in aperm.default(map, c(2, 1, 3)) :
primeiro argumento inválido: deve ser um array
Além disso: Warning message:
In get_googlemap(center = location, zoom = zoom, maptype = maptype, :
HTTP 400 Bad Request
>
我遇到了同样的问题并且更新了我的google api密钥。