none
DirectionsManager displaying terse directions v8 RRS feed

  • Question

  • Hello there,

    Is there a way ( in v8 ) , to just show the summary of the fastest route ?  I don't need (or have space) , to show the route selector, and the full list of detailed directions.

    I just want to show the most pertinent info , like 

    • miles between two points
    • time of travel 

    ( maybe in future , user can decide if he wants details, then we can make another request for that data )

    Thanks.

    Monday, July 18, 2016 7:49 PM

Answers

  • You can already do this. Don't use the itinerary output panel, instead access the raw route information and create you display as you like. You can easily do this using the directions updated event.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Tuesday, July 19, 2016 3:10 AM
    • Marked as answer by Rybolt Tuesday, July 19, 2016 8:33 PM
    Tuesday, July 19, 2016 3:10 AM
  • UPDATE: I am getting in the callback ( directionsUpdated ) , twice!  I thought it only got invoked when completed ( not continual updates ).  Has it changed from v7 ?


    Thank you, after knowing the class name from debugger { on callback }:

    args.routeSummary[0].time
    40709
    args.routeSummary[0].distance
    714.181058

    found an example on MSDN, here => 

    MSDN Example




    • Edited by Rybolt Tuesday, July 19, 2016 2:58 PM new info
    • Marked as answer by Rybolt Tuesday, July 19, 2016 8:33 PM
    Tuesday, July 19, 2016 2:44 PM
  • Good news, the issue with the callback function being called twice has been resolved in the experimental branch and will be in the main release branch in a couple of weeks.

    [Blog] [twitter] [LinkedIn]

    Friday, August 26, 2016 5:16 PM

All replies

  • You can already do this. Don't use the itinerary output panel, instead access the raw route information and create you display as you like. You can easily do this using the directions updated event.

    [Blog] [twitter] [LinkedIn]

    • Proposed as answer by Ricky_Brundritt Tuesday, July 19, 2016 3:10 AM
    • Marked as answer by Rybolt Tuesday, July 19, 2016 8:33 PM
    Tuesday, July 19, 2016 3:10 AM
  • UPDATE: I am getting in the callback ( directionsUpdated ) , twice!  I thought it only got invoked when completed ( not continual updates ).  Has it changed from v7 ?


    Thank you, after knowing the class name from debugger { on callback }:

    args.routeSummary[0].time
    40709
    args.routeSummary[0].distance
    714.181058

    found an example on MSDN, here => 

    MSDN Example




    • Edited by Rybolt Tuesday, July 19, 2016 2:58 PM new info
    • Marked as answer by Rybolt Tuesday, July 19, 2016 8:33 PM
    Tuesday, July 19, 2016 2:44 PM
  • The directionsUpdated event will fire every time the directions change. If you drag the route or calculate a new route, this event will fire.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 19, 2016 5:26 PM
  • The two steps you are seeing are this;

    • Input locations are being geocoded and displayed on the map.
    • Route is being calculated for the locations, using the geocoded coordinates, and the route is displayed on the map.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 19, 2016 7:00 PM
  •  @Ricky 

    Easily see this if you just tweak the innerHTML += , with the MSDN example.

    or put a console.log here:

       Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', () => {
                            console.log('event fired');
                            document.getElementById('printoutPanel').innerHTML = 'Directions updated event fired!!!';
                        });

    Still don't know why the event gets called multiple times (bug?) .  I even use maxRoutes:1 , to ensure it's not getting updated by diff. routes.

    • Edited by Rybolt Tuesday, July 19, 2016 8:54 PM
    Tuesday, July 19, 2016 8:32 PM
  • Possibly a bug. Will have team take a look. Shouldn't be an issue unless you are doing some complex operation when the event fires.

    [Blog] [twitter] [LinkedIn]

    Tuesday, July 19, 2016 9:48 PM
  • I agree this is not a huge issue, but being aware of the behavior is important for any code in that callback.

    Maybe something in the eventArgs in the callback could be used to determine last (completed) callback.

    Wednesday, July 20, 2016 5:40 PM
  • Adding supplement question , as it relates to 'terse' directions.

    In a multi-leg (way point) direction mapping, Is there a way to have the legs collapsed (in the directions output)  by default ?

    Right now they are expanded by default, and can collapse per user click.

    I believe the div starting point is around here:

     div.dirLeg.nLegs.firstLeg > table > tbody > tr > td.dirLegIcons

    Thanks!


    • Edited by Rybolt Friday, August 12, 2016 8:02 PM
    Friday, August 12, 2016 8:01 PM
  • Not at the moment, but I'll add that as a feature request.

    [Blog] [twitter] [LinkedIn]

    Friday, August 12, 2016 11:56 PM
  • Good news, the issue with the callback function being called twice has been resolved in the experimental branch and will be in the main release branch in a couple of weeks.

    [Blog] [twitter] [LinkedIn]

    Friday, August 26, 2016 5:16 PM