none
DirectionsManager.removeWaypoint() doesn't seem to work RRS feed

  • Question

  • Hi,

    I'm working on a project where I want to remove a Waypoint and add a different one. What was happening is that I would call removeWaypoint on my DirectionsManager object, then add the new waypoint, and I would end up with three waypoints. It turns out that removeWaypoint wasn't actually removing any waypoints.

    Here is a sample of what I mean:

    let waypoints = this.directionsManager.getAllWaypoints();
    
    // When I look with the debugger here, waypoints would be an array of size 2.
    
    for (const waypoint of waypoints) {
        this.directionsManager.removeWaypoint(waypoint);
    }
    
    waypoints = this.directionsManager.getAllWaypoints();
    
    // When I look with the debugger here, waypoints would still be an array of size 2, meaning that nothing was removed.

    The other thing I tried was to use the index to remove the waypoint. When I do that, I get an exception.

    let waypoints = this.directionsManager.getAllWaypoints();
    
    // When I look with the debugger here, waypoints would be an array of size 2.
    
    this.directionsManager.removeWaypoint(0);
    
    waypoints = this.directionsManager.getAllWaypoints();
    
    // When I look with the debugger here, waypoints would still be an array of size 2, meaning that nothing was removed.

    The only thing I can guess is that there is some issue because I add the original two waypoints through the directions panel, and then try to modify them programmatically. Does anyone have any ideas?


    • Edited by 23423423423 Sunday, August 13, 2017 4:52 PM spelling
    Sunday, August 13, 2017 4:52 PM

Answers

All replies