R中的Mapdist传递坐标时返回错误

时间:2019-05-03 08:16:37

标签: r google-maps-api-3 ggmap

我正在尝试在R中的ggmap包中使用mapdist函数,但收到错误警告:反向地址解析失败,并出现错误:该API项目无权使用此API。下面是我的代码

> p1
[1] -77.1365  38.8190
> p2
[1] -77.0625  38.8049
> mapdist(p1, p2, mode = "walking")
Warning: Reverse geocoding failed with error:
This API project is not authorized to use this API.

Warning: Reverse geocoding failed with error:
This API project is not authorized to use this API.

# A tibble: 1 x 3
  from  to    mode   
  <chr> <chr> <chr>  
1 NA    NA    walking

我已经测试了以下代码,以测试是否已在Google控制台中正确启用了所有API,并且可以正常工作

> (wh <- as.numeric(geocode("the white house, dc")))
Source : https://maps.googleapis.com/maps/api/geocode/json?address=the+white+house,+dc&key=xxx
[1] -77.03653  38.89768
> (lm <- as.numeric(geocode("lincoln memorial washington dc")))
Source : https://maps.googleapis.com/maps/api/geocode/json?address=lincoln+memorial+washington+dc&key=xxx
[1] -77.05018  38.88927
> mapdist(wh, lm, mode = "walking")

任何帮助将不胜感激。谢谢!

0 个答案:

没有答案