将R package ggmap与Google Directions API令牌一起使用

时间:2016-06-14 16:17:16

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

我正在使用ggmap' s" route"使用Google的行车路线API绘制行车路线图。我可能需要超过每日2,500个API限制。我知道要超过该阈值,我必须支付0.50美元/ 1000美元的点击费并注册Google Developers API令牌。但是,我没有在ggmap库或路由功能中看到任何允许我输入我的令牌和密钥信息的参数,以便我可以超过阈值。我错过了什么?

1 个答案:

答案 0 :(得分:0)

我已经编写了包googleway来访问google maps API,您可以在其中指定令牌密钥

例如

library(googlway)

key <- "your_api_key"
google_directions(origin = "MCG, Melbourne",
                  destination = "Flinders Street Station, Melbourne",
                  key = key,
                  simplify = F) ## use simplify = T to return a data.frame

[1] "{"                                                                                                                                                                                                                                                                                                                                                
[2] "   \"geocoded_waypoints\" : ["                                                                                                                                                                                                                                                                                                                    
[3] "      {"                                                                                                                                                                                                                                                                                                                                          
[4] "         \"geocoder_status\" : \"OK\","                                                                                                                                                                                                                                                                                                           
[5] "         \"partial_match\" : true,"                                                                                                                                                                                                                                                                                                               
[6] "         \"place_id\" : \"ChIJIdtrbupC1moRMPT0CXZWBB0\","                                                                                                                                                                                                                                                                                         
[7] "         \"types\" : ["                                                                                                                                                                                                                                                                                                                           
[8] "            \"establishment\","                                                                                                                                                                                                                                                                                                                   
[9] "            \"point_of_interest\","                                                                                                                                                                                                                                                                                                               
[10] "            \"train_station\","                                                                                                                                                                                                                                                                                                                   
[11] "            \"transit_station\""                                                                                                                                                                                                                                                                                                                  
[12] "         ]"                                                                                                                                                                                                                                                                                                                                       
[13] "      },"                                                                                                                                                                                                                                                                                                                                         
[14] "      {"                                                                                                                                                                                                                                                                                                                                          
[15] "         \"geocoder_status\" : \"OK\","                                                                                                                                                                                                                                                                                                           
[16] "         \"place_id\" : \"ChIJSSKDr7ZC1moRTsSnSV5BnuM\","                                                                                                                                                                                                                                                                                         
[17] "         \"types\" : ["                                                                                                                                                                                                                                                                                                                           
[18] "            \"establishment\","                                                                                                                                                                                                                                                                                                                   
[19] "            \"point_of_interest\","                                                                                                                                                                                                                                                                                                               
[20] "            \"train_station\","                                                                                                                                                                                                                                                                                                                   
[21] "            \"transit_station\""                                                                                                                                                                                                                                                                                                                  
[22] "         ]"                                                                                                                                                                                                                                                                                                                                       
[23] "      }"                                                                                                                                                                                                                                                                                                                                          
[24] "   ],"                                                                                                                                                                                                                                                                                                                                            
[25] "   \"routes\" : ["
... etc