leaflet-routing-machine
leaflet-routing-machine copied to clipboard
hide panel when routing control has empty waypoints
If no waypoints specified, the panel will appears as a line. Could we hide it ?
var routingControl = L.Routing.control({
createMarker: function() {
return null;
},
lineOptions: { styles: [{ color: '#2598FF', opacity: 1, weight: 5 }] },
fitSelectedRoutes: false
}).addTo(map);
Hi, and thanks for reporting. This is on my todo list, and has even been implemented in the develop
branch. Sadly, that branch has diverged a bit too much from master
, so given that I don't work actively on LRM at the moment, I don't think I will have time to pick that up any time soon.
You can get a feel for how it was implemented here: https://github.com/perliedman/leaflet-routing-machine/blob/develop/src/control.js#L447
I'll keep this open to remember to fix this. Any help fixing this would of course be very welcome!
Use map.removeControl(route) .. it worked for me
Use map.removeControl(route) .. it worked for me
can you explain how to use it?
Hopefully this will help you
// MAP DIV
// Initialise Map const map = L.map('mapid').setView([51.505, -0.09], 13);
// this will create your routing control const routingControl = map.routing.control({ collapsible: true, show: false, lineOptions: { addWaypoints: false, }, waypoints: [ L.latLng(fromlat, fromlng), L.latLng(tolat, tolong), ], router: map.routing.router({ costing: 'auto' }), }).addTo(map);
// for removing routing controls routingControl.setWaypoints([]); // this will work
// OR this will also work
map.removeControl(routingControl)