Description Usage Arguments Details Value Examples
View source: R/distanceMatrix.R
Get driving distance and driving time matrices between coordinates using the Google Maps Distance Matrix API (requires API key).
1 | distanceMatrix(origins, destinations, units = "metric", key, pause.time = 0.02)
|
origins |
Origin points. A |
destination |
Destination points. A |
units |
Use |
key |
API key. The distance matrix API must be enabled first. |
pause.time |
Amount of time in seconds to wait after a request (if performing multiple requests in a loop). |
An API key must first be obtained to use the API and you need to enable the Distance Matrix API. If you are over your query limit, the function will issue a warning.
distance |
Driving distance matrix between origin and destination
points. If no route is found it will return |
duration |
Driving time duration (in seconds) between origin and
destination points. If no route is found it will return |
origin_addresses |
The addresses of the origin points. |
destination_addresses |
The addresses of the destination points. |
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
places <- rbind(geocodeAddress("Boston")$crd,
geocodeAddress("New York")$crd,
geocodeAddress("Washington DC")$crd)
# Format looks like this:
# lon lat
# [1,] -71.05888 42.36008
# [2,] -74.00594 40.71278
# [3,] -77.03687 38.90719
distanceMatrix(origins = places, destinations = places, key = YOUR.API.KEY)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.