library(xml2)
doc = as_xml_document(response_matrix)
mp_get_matrix(doc, value = "distance_m")
mp_get_matrix(doc, value = "distance_text")
mp_get_matrix(doc, value = "duration_s")
mp_get_matrix(doc, value = "duration_text")
if (FALSE) {
# Text file with API key
key = readLines("~/key")
locations = c("Tel-Aviv", "Jerusalem", "Neve Shalom")
# Driving times
doc = mp_matrix(
origins = locations,
destinations = locations,
mode = "driving",
departure_time = Sys.time() + as.difftime(10, units = "mins"),
key = key
)
mp_get_matrix(doc, value = "distance_m")
mp_get_matrix(doc, value = "distance_text")
mp_get_matrix(doc, value = "duration_s")
mp_get_matrix(doc, value = "duration_text")
mp_get_matrix(doc, value = "duration_in_traffic_s")
mp_get_matrix(doc, value = "duration_in_traffic_text")
# Public transport times
doc = mp_matrix(
origins = locations,
destinations = locations,
mode = "transit",
key = key
)
mp_get_matrix(doc, value = "distance_m")
mp_get_matrix(doc, value = "distance_text")
mp_get_matrix(doc, value = "duration_s")
mp_get_matrix(doc, value = "duration_text")
}
Run the code above in your browser using DataLab