【发布时间】:2018-11-17 06:51:33
【问题描述】:
我正在尝试使用邮政编码和净值在澳大利亚制作密度图,以了解客户来自哪里机场停车场(大学项目)
我已经为谷歌地图设置了一个 API 密钥。我正在使用 ggmap,但不断收到 request denied 错误。
Source : https://maps.googleapis.com/maps/api/staticmap?center=Gold%20Coast&zoom=12&size=640x640&scale=2&maptype=terrain&key=xxx
Source : https://maps.googleapis.com/maps/api/geocode/json?address=Gold%20Coast&key=xxx
Error in data.frame(ll.lat = ll[1], ll.lon = ll[2], ur.lat = ur[1], ur.lon = ur[2]) :
arguments imply differing number of rows: 0, 1
In addition: Warning message:
geocode failed with status REQUEST_DENIED, location = "Australia"
我已经尝试了几种检索地图数据的方法,但总是遇到同样的错误。
请帮助 :) 任何建议表示赞赏!另外,如果有更好的方法建议,我会全神贯注:)
这里是使用的代码:
if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap", ref = "tidyup")
library("ggmap", lib.loc="C:/Program Files/Microsoft/R Open/R-3.5.0/library")
key <- register_google(key = "###API KEY###")
p <- ggmap(get_googlemap(center = "Australia", source = 'google',
zoom = 11, scale = 2,
maptype ='terrain',
color = 'color'))
p + geom_point(aes(x = hmapf$Postcode, y = hmapf$`Net Value`, colour = "Pink"), data = hmapf, size = 0.5) +
theme(legend.position="bottom"); p
我还尝试了另一种方法:
Australia <- get_map(location="Australia", zoom=3, maptype="terrain")
gg <- ggmap(Australia, extent="normal")
gg <- gg + geom_point(data=pop, aes(x=LONG, y=LAT, color=Density))
gg <- gg + scale_color_viridis()
gg <- gg + theme_map()
gg <- gg + theme(legend.position="none")
gg
我没有任何运气,两者都有同样的错误。 谢谢:)
【问题讨论】:
-
必须是静态地图还是交互式地图?
-
您可能滥用免费套餐,请求过多,并输入了无效的帐单卡。等一三天。
-
您应该将您的项目与结算帐户相关联,或者您每天只能使用该 API 一次
-
@SymbolixAU - 当然地图可以是静态的
-
@hrbrmstr 谢谢,但是这个错误从 API 上线的那一刻起就发生了。在谷歌控制台中,它显示 API 正在触发并且请求已成功。