none
How to display a Truck Route in a Map? RRS feed

  • Question

  • Hello.

    I'm trying to display a route using Imagery API without success. I tried to add parameters like vehicleHeight but it doesn't change anything.

    I also verified all documentation I could find about Trucks API and it doesn't specify anywhere how to display its route on the map.

    https://msdn.microsoft.com/en-us/library/mt814923.aspx

    Thank you, 

    Pedro



    • Edited by pszor Monday, August 20, 2018 9:11 PM
    Monday, August 20, 2018 9:09 PM

All replies

  • Hi Pedro,

    There is a direct example for truck routing in the Interactive SDK at https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/directionscreatetruckroute

    You will find if you plot this same route for a car that the route will go through a tunnel.

    You can also try the demo at https://www.microsoft.com/en-us/maps/truck-routing

    Sincerely,

    IoTGirl

    Tuesday, August 21, 2018 12:51 AM
    Owner
  • Is it possible to genererate a link like this but for trucks?

    https://dev.virtualearth.net/REST/v1/Imagery/Map/imagerySet/Routes/travelMode?waypoint.1=routeWaypoint1&waypoint.2=routeWaypoint2&waypoint.n=routeWaypointn&mapArea=mapArea&avoid=avoidOptions&pushpin=pushpin&timeType=timeType&dateTime=dateTime&maxSolutions=maxSolutions&distanceBeforeFirstTurn=distanceBeforeFirstTurn&mapLayer=mapLayer&format=format&mapMetadata=mapMetadata&key=BingMapsKey

    Also, the first link posted by you doesn't provide the right answer for the two points I'm testing but the REST service does.

    Tuesday, August 21, 2018 7:50 AM
  • Hi Pedro,

    The first link you gave has the call for truck routing with waypoints ( https://msdn.microsoft.com/en-us/library/mt814923.aspx )

    https://dev.virtualearth.net/REST/v1/Routes/Truck?wayPoint.1=wayPoint1&viaWaypoint.2=viaWaypoint2&waypoint.3=wayPoint3&wayPoint.n=wayPointn&heading=heading&optimize=optimize&avoid=avoidOptions&distanceBeforeFirstTurn=distanceBeforeFirstTurn&routeAttributes=routeAttributes&dateTime=dateTime&tolerances=tolerances&distanceUnit=distanceUnit&vehicleHeight=vehicleHeight&vehicleWidth=vehicleWidth&vehicleLength=vehicleLength&vehicleWeight=vehicleWeight&vehicleAxles=vehicleAxles&vehicleTrailers=vehicleTrailers&vehicleSemi=vehicleSemi&vehicleMaxGradient=vehicleMaxGradient&vehicleMinTurnRadius=vehicleMinTurnRadius&vehicleAvoidCrossWind=vehicleAvoidCrossWind&vehicleAvoidGroundingRisk=vehicleAvoidGroundingRisk&vehicleHazardousMaterials=vehicleHazardousMaterials&vehicleHazardousPermits=vehicleHazardousPermits&key=BingMapsKey
    

    Sincerely,

    IoTGirl

    Tuesday, August 21, 2018 3:29 PM
    Owner
  • Yes, but it only shows the result as JSON or XML file. I would like to show it on a map. I only can do it using the Imagery API (see my last answer) but it doesn't support the truck restrictions.




    • Edited by pszor Tuesday, August 21, 2018 7:58 PM
    Tuesday, August 21, 2018 7:54 PM
  • Hi Pedro,

    What happens when you use Directions Manager?

    1. Truck routing https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/directionscreatetruckroute

    2. Add Waypoints https://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk/directionsaddwaypoint

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(40.418386, -80.019262),
        zoom: 16 });
    Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
        var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
        directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('printoutPanel') });
        directionsManager.setRequestOptions({
            routeMode: Microsoft.Maps.Directions.RouteMode.truck,
            vehicleSpec: {
                dimensionUnit: 'ft',
                weightUnit: 'lb',
                vehicleHeight: 5,
                vehicleWidth: 3.5,
                vehicleLength: 30,
                vehicleWeight: 30000,
                vehicleAxles: 3,
                vehicleTrailers: 2,
                vehicleSemi: true,
                vehicleMaxGradient: 10,
                vehicleMinTurnRadius: 15,
                vehicleAvoidCrossWind: true,
                vehicleAvoidGroundingRisk: true,
                vehicleHazardousMaterials: 'F',
                vehicleHazardousPermits: 'F'
            }
        });
        var wp1 = new Microsoft.Maps.Directions.Waypoint({
            address: '590 Crane Ave, Pittsburgh, PA',
            location: new Microsoft.Maps.Location(40.419228, -80.018138)
        });
        var wp2 = new Microsoft.Maps.Directions.Waypoint({
            address: '600 Forbes Ave, Pittsburgh, PA',
            location: new Microsoft.Maps.Location(40.437550, -79.993610)
        });
        directionsManager.addWaypoint(wp1);
        directionsManager.addWaypoint(wp2);
        directionsManager.calculateDirections();
    });

    You should be able to add up to 20 waypoints on your route using this method.

    Sincerely,

    IoTGirl

    Wednesday, August 22, 2018 5:17 AM
    Owner
  • I think I found the problem but I would be really thankful if you can help me.

    If you run this case, you can see that the left bridge is avoided. In fact, that is an old bridge where is banned the circulation of heavy vehicles (weight above 3500 kg according to the EU legislation).

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(41.583948, -8.462833),
        zoom: 16 });
    Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
        var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
        directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('printoutPanel') });
        directionsManager.setRequestOptions({
            routeMode: Microsoft.Maps.Directions.RouteMode.truck,
            vehicleSpec: {
                dimensionUnit: 'm',
                weightUnit: 'kg',
                vehicleHeight: 2,
                vehicleWidth: 2,
                vehicleLength: 5,
                vehicleWeight: 4000,
                vehicleAxles: 2,
                vehicleTrailers: 0,
                vehicleSemi: false,
                vehicleMaxGradient: 10,
                vehicleMinTurnRadius: 15,
                vehicleAvoidCrossWind: true,
                vehicleAvoidGroundingRisk: true,
                vehicleHazardousMaterials: 'F,G,C,E',
                vehicleHazardousPermits: 'F,G,C,E',
            }
        });
        var wp1 = new Microsoft.Maps.Directions.Waypoint({
            address: '41.583350, -8.448505',
            location: new Microsoft.Maps.Location(41.583350, -8.448505)
        });
        var wp2 = new Microsoft.Maps.Directions.Waypoint({
            address: '41.599900, -8.466137',
            location: new Microsoft.Maps.Location(41.599900, -8.466137)
        });
        directionsManager.addWaypoint(wp1);
        directionsManager.addWaypoint(wp2);
        directionsManager.calculateDirections();
    });

    However, if we change the starting point a little bit to the left, that bridge isn't avoided.

    var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
        /* No need to set credentials if already passed in URL */
        center: new Microsoft.Maps.Location(41.583948, -8.462833),
        zoom: 16 });
    Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
        var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);
        directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('printoutPanel') });
        directionsManager.setRequestOptions({
            routeMode: Microsoft.Maps.Directions.RouteMode.truck,
            vehicleSpec: {
                dimensionUnit: 'm',
                weightUnit: 'kg',
                vehicleHeight: 2,
                vehicleWidth: 2,
                vehicleLength: 5,
                vehicleWeight: 4000,
                vehicleAxles: 2,
                vehicleTrailers: 0,
                vehicleSemi: false,
                vehicleMaxGradient: 10,
                vehicleMinTurnRadius: 15,
                vehicleAvoidCrossWind: true,
                vehicleAvoidGroundingRisk: true,
                vehicleHazardousMaterials: 'F,G,C,E',
                vehicleHazardousPermits: 'F,G,C,E',
            }
        });
        var wp1 = new Microsoft.Maps.Directions.Waypoint({
            address: '41.584425, -8.462281',
            location: new Microsoft.Maps.Location(41.584425, -8.462281)
        });
        var wp2 = new Microsoft.Maps.Directions.Waypoint({
            address: '41.599900, -8.466137',
            location: new Microsoft.Maps.Location(41.599900, -8.466137)
        });
        directionsManager.addWaypoint(wp1);
        directionsManager.addWaypoint(wp2);
        directionsManager.calculateDirections();
    });

    How can I solve this problem? 

    Thank you


    • Edited by pszor Wednesday, August 22, 2018 9:25 AM
    Wednesday, August 22, 2018 9:24 AM
  • Hi Pedro,

    I am now VERY confused by your issue.  Firstly you said you could not display a route and I gave you a solution to display a route.  Then you said you could not display way points and I gave you a solution to display waypoints, which was actually the same answer to the first question.

    You are now changing your question yet again and I will now provide you a third answer.  Data issues are reported to the data provider through the feedback interface as described here https://social.msdn.microsoft.com/Forums/en-US/da4a854c-2a50-43ca-a25a-c376de79ded8/report-a-data-issue?forum=bingmaps

    As your original question was answered by my first response, I have suggested it above.

    Sincerely,

    IoTGirl

    Wednesday, August 22, 2018 4:45 PM
    Owner
  • hello <g class="gr_ gr_12 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del multiReplace" data-gr-id="12" id="12">pszor</g>,
    Can you provide me the code sample how you accomplish this <g class="gr_ gr_59 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation multiReplace" data-gr-id="59" id="59">task.</g>

    Regards

    Monday, October 8, 2018 2:01 PM
  • Hi Abhishek,

    All code needed is included in the answers above.

    Sincerely,

    IoTGirl

    Monday, October 8, 2018 3:24 PM
    Owner