airports[c("name", "type")]
## class : SpatialPointsDataFrame
## features : 2
## extent : 8.785862, 10.00565, 53.05229, 53.632 (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
## variables : 2
## names : name, type
## min values : Bremen, major
## max values : Hamburg, major
library(osrm)
route <- osrmRoute(airports[1, ], airports[2, ], sp = TRUE)
leaflet(width = "100%") %>% addProviderTiles("CartoDB") %>%
addMarkers(data = airports, popup = ~ name) %>%
addPolylines(data = route) %>%
addControl(
sprintf("<b>Duration</b>: %i min",
as.integer(route$duration))
)