我通常使用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)
我不确定问题出在哪里。香港专业教育学院尝试了新的API密钥,但没有运气。有输入吗?
错误显示为:
无法打开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状态为download.file(url,destfile = destfile,安静=!消息,模式=“ wb”):无法打开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'
答案 0 :(得分:4)
更新时间:2018年12月1日,适用于ggmap 2.7.904和当前的Google Cloud API
您的API密钥是
查看此step-by-step tutorial on Stackoverflow。
要检查问题出在哪里,请键入geocode("Houston", output = "all")
并查看错误消息。
> geocode("Houston", output = "all")
$error_message
[1] "The provided API key is invalid."
$results
list()
$status
[1] "REQUEST_DENIED"
这表示您提供了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"
这表示您的API密钥有效,但您不允许使用此特定的API。切记:Google对于每种小的请求(静态地图,路线,地理编码等)都有一个API。因此,您需要转到Google控制台并为正确的API启用此API密钥,在本例中为地理编码。
> ggmap(get_map("Houston"))
答案 1 :(得分:2)
如果您的API密钥有效,您还可以使用11 verbose stack Error: exited with error code: 128
11 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/util/finished.js:12:19)
11 verbose stack at ChildProcess.emit (events.js:182:13)
11 verbose stack at maybeClose (internal/child_process.js:962:16)
11 verbose stack at Socket.stream.socket.on (internal/child_process.js:381:11)
11 verbose stack at Socket.emit (events.js:182:13)
11 verbose stack at Pipe._handle.close (net.js:606:12)
12 verbose cwd /root/tmp
13 verbose Linux 3.10.0-957.1.3.el7.x86_64
14 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "git+ssh://git@bitbucket.org/user/repo.git"
15 verbose node v10.14.1
16 verbose npm v6.4.1
17 error Error while executing:
17 error /bin/git ls-remote -h -t ssh://git@bitbucket.org/user/repo.git
17 error
17 error fatal: Cannot change to '/root/tmp/..': Permission denied
17 error
17 error exited with error code: 128
18 verbose exit [ 1, true ]
绘制交互式地图
- name: top-name
hosts: myhost
tasks:
- name: task-name
become: true
environment:
PATH: /usr/local/bin:/bin:{{ ansible_env.PATH }}
command: npm i git+ssh://git@bitbucket.org/user/repo.git
args:
chdir: /root/tmp
register: out
library(googleway)