Reputation: 2046
I would like to ask you if there is some way how to disable/enable routing plugin
The control is added into the leaflet in this way:
var map = L.map('map');
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
]
}).addTo(map);
Does anybody have an idea how to dynamically disable/enable this control?
Upvotes: 1
Views: 2340
Reputation: 986
It looks like L.Routing.Control
extends L.Routing.Itinerary
which implements show() and hide() methods. So you should be able to do something like this:
var routeControl = L.Routing.control({
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
]
}).addTo(map);
//.. Some other code ..
if(hide)
routeControl.hide();
else
routeControl.show();
Upvotes: 2