简体   繁体   English

R:ggmap 中的 get_map() 错误

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

I am trying to plot a simple map in R using function get_map() for a certain location.我正在尝试使用函数 get_map() 在 R 中为某个位置绘制一个简单的地图。 Following is my code:以下是我的代码:

eg例如

get_map(location = "texas", zoom = 10, source = "google")

I've tried different parameters.我尝试了不同的参数。 The error I'm getting is following:我得到的错误如下:

Error in aperm.default(map, c(2, 1, 3)) : 
perm' is of wrong length 3 (!= 2)

What is exactly happening in the background & how do I fix it?后台到底发生了什么?我该如何解决? I checked all the possible blogs I could, no one seems to get this error.我检查了所有可能的博客,似乎没有人收到此错误。

Please help!请帮忙!

This error occurs due to the base url.此错误是由于基本 url 而发生的。 In CRAN version , the base url is not secure.CRAN version中,基本 url 是不安全的。 Use dev version of this package from {github} instead & function runs fine.使用来自 {github} 的这个包的开发版本 & 函数运行正常。 Use devtools::install_github(""dkahle/ggmap") to install library from github使用devtools::install_github(""dkahle/ggmap")从 github 安装库

I had the same problem and updating my google api key worked out.我遇到了同样的问题,并且更新了我的 google api 密钥。

I'm with ggmap from github but facing de same problem here... 我正在使用来自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
> 

Navigate directly to the URL generated, and you should see a different error message that might be more informative:直接导航到生成的 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>

In my case, it said my API key was not valid for this API, although up to that point the error just said the same thing about就我而言,它说我的 API 密钥对此 API 无效,尽管到那时错误只是说了同样的事情

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

and

HTTP 400 Bad Request

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

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