I D*_*oro 6 gis r ggplot2 ggmap
我通常用来ggmap在简单的城市地图上绘制点.今天这样做时,我遇到了一个新的错误,禁止我使用该功能get_map()
#get API key @ https://developers.google.com/places/web-service/get-api-key
key<-"AIzaSyCYgKKt2fn7Crt-V6Hnc5aw5lSfy7XLQ-Y"
register_google(key = key)
atw<- get_map(location=c(-88.68,42.14), zoom=10, scale=2)
Run Code Online (Sandbox Code Playgroud)
我不确定问题出在哪里.我尝试了一个新的API密钥,但没有运气.有什么输入?
错误如下:
无法打开网址' https://maps.googleapis.com/maps/api/staticmap?center=42.14,-88.68&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&key=AIzaSyCYgKKt2fn7Crt-V6Hnc5aw5lSfy7XLQ-Y':HTTP状态为download.file中的'403 Forbidden'错误(url,destfile = destfile,quiet =!messaging,mode ="wb"):无法打开网址' https://maps.googleapis.com/maps/api/staticmap?center= 42.14,-88.68&zoom = 10&size = 640x640&scale = 2&maptype = terrain&language = en-EN&key = AIzaSyCYgKKt2fn7Crt-V6Hnc5aw5lSfy7XLQ-Y '
更新:2018年12月1日适用于ggmap 2.7.904和最新的Google Cloud API
您的API密钥是
要检查问题所在,请键入geocode("Houston", output = "all")并查看错误消息。
> geocode("Houston", output = "all")
$error_message
[1] "The provided API key is invalid."
$results
list()
$status
[1] "REQUEST_DENIED"
Run Code Online (Sandbox Code Playgroud)
这意味着您提供了Google不能识别的API密钥。也许打错了字,或者复印错了?有时会出现一些奇怪的问题,因此请在Google控制台中生成一个新的API密钥,然后重试。
> geocode("Houston", output = "all")
$`error_message`
[1] "This API project is not authorized to use this API."
$results
list()
$`status`
[1] "REQUEST_DENIED"
Run Code Online (Sandbox Code Playgroud)
这意味着您的API密钥有效,但是您不允许使用此特定的API。切记:Google对于每种小的请求(静态地图,路线,地理编码等)都有一个API。因此,您需要转到Google控制台并为正确的API(在本例中为Geocoding)启用此API密钥。
> ggmap(get_map("Houston"))
Run Code Online (Sandbox Code Playgroud)