How do I get driving time from Google Maps API?
问题 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(origin, destination){ xml.url <- paste0('http://maps.googleapis.com/maps/api/distancematrix/xml?origins=', origin, '&destinations=', destination, '&mode=driving&sensor=false') xmlfile <- xmlParse(getURL(xml.url)) dist <- xmlValue(xmlChildren(xpathApply(xmlfile,"//distance")[[1]])$value) distance <- as.numeric(sub(" km", "", dist)) time <-