It's not entirely clear what you want, given that you have just written a title, so I have to guess you want to export a route as GeoJSON.
You can achieve this by listening to the routeselected event on the control. When a route is selected, it will fire and the event's route property will contain the actual route. While there isn't a method to turn the route into GeoJSON, you can extract the route's coordinates from route.coordinates, it's an array of L.LatLng objects that you for example can turn into a LineString geometry. You can also access the waypoints, if you need to serialize them as well.
It's not entirely clear what you want, given that you have just written a title, so I have to guess you want to export a route as GeoJSON.
You can achieve this by listening to the
routeselected
event on the control. When a route is selected, it will fire and the event'sroute
property will contain the actual route. While there isn't a method to turn the route into GeoJSON, you can extract the route's coordinates fromroute.coordinates
, it's an array ofL.LatLng
objects that you for example can turn into aLineString
geometry. You can also access the waypoints, if you need to serialize them as well.