ggmap:带trek的空数据帧

ggmap:带trek的空数据帧,r,ggmap,R,Ggmap,我已使用以下代码从github存储库安装了最新版本的ggmap: devtools::install_github("dkahle/ggmap", ref = "tidyup") 我已经启用了“地理编码API”选项,启用了计费,并提供了我的Google API密钥。然后,我尝试使用trek函数重新运行代码,并使用geom\u path在地图上绘制路径。这段代码在几个月前(2018年6月)还在运行,但现在我发现了错误: FUN(X[[i]],…)中出错:未找到对象“lon” 然后,我尝试在tre

我已使用以下代码从github存储库安装了最新版本的ggmap:

devtools::install_github("dkahle/ggmap", ref = "tidyup")
我已经启用了“地理编码API”选项,启用了计费,并提供了我的Google API密钥。然后,我尝试使用
trek
函数重新运行代码,并使用
geom\u path
在地图上绘制路径。这段代码在几个月前(2018年6月)还在运行,但现在我发现了错误:

FUN(X[[i]],…)中出错:未找到对象“lon”

然后,我尝试在trek vignette中运行该示例,并得到了相同的错误消息。因此,使用小插曲中的示例:

from <- "houston, texas"
to <- "waco, texas"
trek_df <- trek(from, to, structure = "route")
qmap("college station, texas", zoom = 8) +
  geom_path(
    aes(x = lon, y = lat),  colour = "blue",
    size = 1.5, alpha = .5,
    data = trek_df, lineend = "round"
  )
为了让这个功能正常工作,我还需要和谷歌做些什么吗?谢谢你的帮助。

最可能的原因是您没有在Google控制台中启用方向API

解释
trek()
正在调用Directions API,如下所示:

> trek_df <- trek(from, to, structure = "route")
Source : https://maps.googleapis.com/maps/api/directions/json?origin=houston%2C%20texas&destination=waco%2C%20texas&mode=driving&units=metric&alternatives=false&key=xxx

> trek_df <- trek(from, to, structure = "route")
Source : https://maps.googleapis.com/maps/api/directions/json?origin=houston%2C%20texas&destination=waco%2C%20texas&mode=driving&units=metric&alternatives=false&key=xxx
> qmap("college station, texas", zoom = 8) +
+     geom_path(
+         aes(x = lon, y = lat),  colour = "blue",
+         size = 1.5, alpha = .5,
+         data = trek_df, lineend = "round"
+     )
Source : https://maps.googleapis.com/maps/api/staticmap?center=college%20station,%20texas&zoom=8&size=640x640&scale=2&maptype=terrain&language=en-EN&key=xxx
Source : https://maps.googleapis.com/maps/api/geocode/json?address=college%20station%2C%20texas&key=xxx