繁体   English   中英

R:ggmap 中的 get_map() 错误

[英]R: Error in get_map() from ggmap

我正在尝试使用函数 get_map() 在 R 中为某个位置绘制一个简单的地图。 以下是我的代码:

例如

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中,基本 url 是不安全的。 使用来自 {github} 的这个包的开发版本 & 函数运行正常。 使用devtools::install_github(""dkahle/ggmap")从 github 安装库

我遇到了同样的问题,并且更新了我的 google api 密钥。

我正在使用来自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
> 

直接导航到生成的 URL,您应该会看到一条不同的错误消息,该消息可能包含更多信息:

https://maps.googleapis.com/maps/api/staticmap?center=31,-97&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=<INSERT_YOUR_KEY>

就我而言,它说我的 API 密钥对此 API 无效,尽管到那时错误只是说了同样的事情

Error in aperm.default(map, c(2, 1, 3)) : 
     invalid first argument, must be an array

HTTP 400 Bad Request

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM