使用API​​密钥在ggmap中映射时出错(禁止使用403) [英] Error when mapping in ggmap with API key (403 Forbidden)

查看:80
本文介绍了使用API​​密钥在ggmap中映射时出错(禁止使用403)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常使用ggmap在简单的城市地图上绘制点.今天在执行此操作时,出现了一个新错误,该错误禁止我使用函数get_map()

I normally use ggmap to plot points on a simple city map. When doing this today I came up on a new error that forbids me to use the function 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)

我不确定问题出在哪里.香港专业教育学院尝试了一个新的API密钥,但没有运气.有输入吗?

I am not sure where the problem is. Ive tried a new API key but no luck. Any input?

该错误显示为:

无法打开URL '

cannot open URL '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 status was '403 Forbidden'Error in download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL '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密钥是

  • 无效(输入错误)/未启用计费(最可能的原因)或
  • 存在一些连接/代理问题.
  • either not valid (wrongly typed) / not enabled for billing (most probable cause) or
  • there are some connection/proxy issues.

查看此有关Stackoverflow的分步教程.

要检查问题出在哪里,请键入geocode("Houston", output = "all")并查看错误消息.

To check what the issue is type geocode("Houston", output = "all") and look at the error message.

> geocode("Houston", output = "all")
$error_message
[1] "The provided API key is invalid."

$results
list()

$status
[1] "REQUEST_DENIED"

这表示您提供了Google不能识别的API密钥.也许打错了字,或者复印了错了?有时会出现一些奇怪的问题,因此,请在Google控制台中生成一个新的API密钥,然后重试.

This means you have provided an API key that is not recognized by Google. Maybe mistyped, maybe miscopied? Sometimes there are weird issues, so generate a new API key in the Google Console and try again.

> geocode("Houston", output = "all")
$`error_message`
[1] "This API project is not authorized to use this API."

$results
list()

$`status`
[1] "REQUEST_DENIED"

这表示您的API密钥有效,但您不允许使用此特定的API.切记:Google对于每种小的请求(静态地图,路线,地理编码等)都有一个API.因此,您需要转到Google控制台并为正确的API启用此API密钥,在本例中为地理编码.

This means your API key is valid, but you have not allowed usage of this specific API. Remember: Google has an API for every little type of request (static maps, directions, geocoding, ...). Therefore, you need to go to your Google Console and enable this API key for the right APIs, in this case Geocoding.

> ggmap(get_map("Houston"))

这篇关于使用API​​密钥在ggmap中映射时出错(禁止使用403)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆