【问题标题】:Using R package ggmap with Google Directions API token将 R 包 ggmap 与 Google Directions API 令牌一起使用
【发布时间】:2016-10-15 11:55:26
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    我已经编写了包 googleway 来访问谷歌地图 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-05
      • 2016-07-16
      • 2016-03-01
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      相关资源
      最近更新 更多