I'm using the google_directions() function to generate driving routes between two coordinates which are generated on clicking at different points in a leaflet map.I would like to show a few possible routes, instead of just one. Setting alternatives = TRUE does not seem to do the job for me. I've tried multiple coordinates.
key <- "my_key"
#lat1,lon1 generated on first click. lat2,lon2 generated on second click.
df <- google_directions(origin = c(lat1,lon1),
destination = c(lat2,lon2),
key = key,
mode = "driving",
simplify = TRUE,
alternatives = TRUE)
pl <- decode_pl(direction_polyline(df))
leaflet() %>% addTiles() %>% addPolylines(data = pl, lng = ~lon, lat = ~lat,group = "route")