Now I would like to use the spliceWaypoints method to start manipulating the waypoints.
Except when I actually check the waypoints without having set any at all there are already 2 empty waypoints without lat lng attributes inside of the waypoints.
this.route.getWaypoints()
Even when trying to clear the waypoints using:
this.route.setWaypoints([]);
The 2 blank waypoints are still in there.
I understand that from the premise of routing you need 2 waypoints but this makes it really hard to start from a blank slate and dynamically add waypoints using the spliceWaypoints method.
Is this meant to be set up like this or is there a way to still clear up the waypoints? Let's say I would wanna start out with a single waypoint and add more right now there is no way to tell if the first waypoint actually is my own or the default blank waypoint without having to check the lat and lng attributes all the time.
Yes, this is the intended way, to make sure the user can always enter a start and end waypoint. You would have to check the existence of lat/lng, or just replace the waypoints that are already there.
I am setting leaflet-routing-machine like so:
Now I would like to use the
spliceWaypoints
method to start manipulating the waypoints. Except when I actually check the waypoints without having set any at all there are already 2 empty waypoints without lat lng attributes inside of the waypoints.Even when trying to clear the waypoints using:
The 2 blank waypoints are still in there.
I understand that from the premise of routing you need 2 waypoints but this makes it really hard to start from a blank slate and dynamically add waypoints using the
spliceWaypoints
method.Is this meant to be set up like this or is there a way to still clear up the waypoints? Let's say I would wanna start out with a single waypoint and add more right now there is no way to tell if the first waypoint actually is my own or the default blank waypoint without having to check the
lat
andlng
attributes all the time.