How do I get driving time from Google Maps API?

前端 未结 2 985
星月不相逢
星月不相逢 2021-01-14 01:24

I use the following function to estimate the time (in hours) to drive a certain distance, assuming an average speed of 65 km/h:

distHoras <- function(orig         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 01:51

    I'm going to throw my own pacakge into the mix that also queries Google's API for you

    (You need a valid Google API key to use it)

    library(googleway)
    
    api_key <- "your_api_key_here"
    
    google_distance(origins = "Paris", 
                                    destinations = "London",
                                    key = api_key)
    
    # $destination_addresses
    # [1] "London, UK"
    # 
    # $origin_addresses
    # [1] "Paris, France"
    # 
    # $rows
    # elements
    # 1 456 km, 456230, 5 hours 31 mins, 19858, 6 hours 12 mins, 22311, OK
    # 
    # $status
    # [1] "OK"
    

提交回复
热议问题