Using the google_directions
function from googleway
package, it does not display the travel time according to google maps browser search.
It seems that it is not taking into account the traffic information.
Example on a busy street in New York.
a <- google_directions(origin = c(40.862804, -73.934743),
destination = "212 5th Ave, New York, NY 10010, USA",
mode = "driving",
units = "metric",
simplify = TRUE,
key = MY_API)
The response at the current time:
b <- direction_steps(a)
total_time <- sum(b$duration$value)/60 # minutes
total_time # minutes
#[1] 26.1166
However, google maps browser displays 35 minutes for the same search time. I checked the routes and it is the same.
Same thing happens using mapsapi
package:
c <- mp_directions(origin = c(-73.934743,40.862804),
destination = "212 5th Ave, New York, NY 10010, USA",
mode = "driving",
key = MY_API)
total_time1 <- sum(mp_get_segments(c)$duration_s)/60 # minutes
total_time1 # minutes
# [1] 26.11667
Does anyone know how to incorporate traffic info into these functions? Or should I conclude google does not provide this level of information?