none
How to save a route and re-render it? RRS feed

  • Question

  • Hi

    1. User will given two GEO points to init a route

    2. User may drag the route just generated

    3. User wants to save the route into db and given a name

    4. Next time,  user wants to retrieve necessary data from db and re-render this route just as the result at step 2.

    I have go through  all API of V8 directions module, such as direction manager, render options, request options....

    I want to know which data in a direction manager or any else I should pick up and save, and how to re-create a direction manager and make it re-render a route just same as before?

    Or is there any way just save the generated route, and how to re draw a route without direction manager?

    Thanks a lot!!!

    Thursday, May 18, 2017 2:59 AM

Answers

  • As you likely found the getAllWaypoints function of the directionsManager only retrieves the waypoints that were specified in the directions manager and does not include any points the user dragged the route to. You can however extract this information from the generated route information. I have put together a code sample that shows this here: http://bingmapsv8samples.azurewebsites.net/#Get%20Dragged%20Route%20Waypoints

    Other than the waypoint information you will want to capture most of the route request information: https://msdn.microsoft.com/library/mt750373.aspx


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Thursday, May 18, 2017 9:26 PM
    • Marked as answer by Chinese_XU Saturday, May 27, 2017 2:43 AM
    Thursday, May 18, 2017 9:26 PM
  • A via waypoint is simply a waypoint that has it's isViapoint option set to true. For example:

    var waypoints = [
    new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(47.67, -122.1) }),
    new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(47.65, -122.2) , isViapoint: true}),
    new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(47.6, -122.33) })
    ];



    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Thursday, May 25, 2017 4:03 PM
    • Marked as answer by Chinese_XU Saturday, May 27, 2017 2:43 AM
    Thursday, May 25, 2017 4:03 PM

All replies

  • As you likely found the getAllWaypoints function of the directionsManager only retrieves the waypoints that were specified in the directions manager and does not include any points the user dragged the route to. You can however extract this information from the generated route information. I have put together a code sample that shows this here: http://bingmapsv8samples.azurewebsites.net/#Get%20Dragged%20Route%20Waypoints

    Other than the waypoint information you will want to capture most of the route request information: https://msdn.microsoft.com/library/mt750373.aspx


    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Thursday, May 18, 2017 9:26 PM
    • Marked as answer by Chinese_XU Saturday, May 27, 2017 2:43 AM
    Thursday, May 18, 2017 9:26 PM
  • Thanks a lot!!! The demo is very helpful.

    By your sample code, it means we should save the originalWaypoints and viaLoc, so that we can re-render the route same as before. Is it right? 

    If there is two original waypoints, and one vialoc been saved, how to put the vialoc into a new direction manager? 

    The constructor of direction manager is : DirectionsManager(map:Map, waypoints?:Waypoint[])

    Should we add the vialoc as a real waypoint to re-render the route?

    Thanks

    Thursday, May 25, 2017 1:24 AM
  • A via waypoint is simply a waypoint that has it's isViapoint option set to true. For example:

    var waypoints = [
    new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(47.67, -122.1) }),
    new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(47.65, -122.2) , isViapoint: true}),
    new Microsoft.Maps.Directions.Waypoint({ location: new Microsoft.Maps.Location(47.6, -122.33) })
    ];



    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Thursday, May 25, 2017 4:03 PM
    • Marked as answer by Chinese_XU Saturday, May 27, 2017 2:43 AM
    Thursday, May 25, 2017 4:03 PM
  • Thanks for the details.
    Saturday, May 27, 2017 2:17 AM