I am thinking of caching the returned routing object in leaflet routing machine. But I cannot serialize the object using JSON.stringify() as it throws up an error stating it's a circular object. I tried to use some java script libraries that can overcome this, but de-serializing it is destroying the object.
var control = L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
],
geocoder: L.Control.Geocoder.nominatim(),
routeWhileDragging: true,
reverseWaypoints: true,
showAlternatives: true,
altLineOptions: {
styles: [
{color: 'black', opacity: 0.15, weight: 9},
{color: 'white', opacity: 0.8, weight: 6},
{color: 'blue', opacity: 0.5, weight: 2}
]
}
});
Help me in storing the control object locally and retrieve it again to add it to the map.