## Not run:
# # Load data
# data("com")
#
# # Get a trip with a id lat lon data.frame
# trips <- osrmTrip(loc = com[1101:1150, c(1,3,4)])
#
# # Display the trip
# sp::plot(trips[[1]]$trip , col = 1:5)
# points(com[1101:1150, 3:4], pch = 20, col = "red", cex = 0.5)
#
# # Map
# if(require("cartography")){
# osm <- getTiles(spdf = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
# tilesLayer(osm)
# plot(trips[[1]]$trip, col = 1:5, add = TRUE)
# points(com[1101:1150, 3:4], pch = 20, col = "red", cex = 0.5)
# }
#
# # Get a trip with a SpatialPointsDataFrame
# trips <- osrmTrip(loc = src)
#
# # Map
# if(require("cartography")){
# osm <- getTiles(spdf = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
# tilesLayer(osm)
# plot(src, pch = 20, col = "red", cex = 2, add = TRUE)
# plot(trips[[1]]$trip, col = 1:5, add = TRUE, lwd=2)
# }
# ## End(Not run)
Run the code above in your browser using DataLab