Disable adding viapoints by clicking on the route line
What's the proper way to disable adding viapoints when clicking on the route line?
I'd rather avoid monkey-patching the lrmControl.options.routeLine. What's the "by-design" approach to achieve this?
Thanx in advance.
@AnixPasBesoin There is no by-design way to do it.
LRM, which we depend on entirely for the UI here, has:
http://www.liedman.net/leaflet-routing-machine/api/#l-routing-plan
which has an addWaypoints: Boolean option which looks like it'll do what you're after.
For some reason, toggling addWaypoint to false didn't disable adding waypoints when clicking on the line.
I'm posting my current very dirty workaround:
_onLineTouched: function (e) {
// <patched>
// var afterIndex = this._findNearestWpBefore(this._findClosestRoutePoint(e.latlng));
// this.fire('linetouched', {
// afterIndex: afterIndex,
// latlng: e.latlng
// });
// </patched>
},
As you can see, I simply commented the _onLineTouched code in L.Routing.Line.js. That's very ugly...
@perliedman Any suggestions on the right way to do this?
addWaypoints should work for this; notice that the option is in plural form and ends with s, not like written in @AnixPasBesoin comment above.
If this doesn't work, I'd step through this line with a debugger to check what's going on: https://github.com/perliedman/leaflet-routing-machine/blob/master/src/control.js#L197
Maybe related: not sure if you're setting addWaypoints when creating the control or toggline the setting after it has been created; in the latter case, see https://github.com/perliedman/leaflet-routing-machine/issues/353