我尝试使用ggmap调用谷歌地图上的地图。以下是示例代码:
然而,这会返回以下错误:
源:https://maps.googleapis.com/maps/api/staticmap?center=24.8,-81.7&zoom=8&size=640x640&scale=4&maptype=satellite&key=(removed发布密钥的键)。
我正在尝试使用ggmap调用谷歌地图上的地图。以下是示例代码:
get_googlemap(center = c(lon = -56.67, lat = 51.47), zoom = 8, size = c(640, 640), scale = 2,
format = "png8", maptype = "satellite")
然而,这会返回以下错误:
源:https://maps.googleapis.com/maps/api/staticmap?center=24.8,-81.7&zoom=8&size=640x640&scale=4&maptype=satellite&key=(removed发布密钥的键)。
Error in aperm.default(map, c(2, 1, 3)) :
invalid first argument, must be an array
In addition: Warning message:
In get_googlemap(center = c(lon = -81.7, lat = 24.8), zoom = 8, :
HTTP 400 Bad Request
我看了一些人遇到类似问题的帖子。看起来在操作API密钥和限制方面有所改动后,问题得以解决。在这个背景下,我已经完成了以下操作:
- 启用计费
- 限制了我的API密钥 - 然而,我没有选项将其限制为“静态地图”。目前我将其限制为“Google Cloud APIs”。与之前相同的错误,但是密钥仍然能被读取。
- 在完成上述操作后,重新启动R并仔细检查我的软件包。
希望能得到帮助,我的实验室同学都没有这个问题,我开始抓狂了,哈哈。