Bing Maps API Distance Matrix Travel Mode is ALWAYS driving

kdglider8 106 Reputation points
2021-03-16T19:32:25.21+00:00

Hi,

I'm on a Basic Education license for the Bing Maps REST services, and I'm using the Distance Matrix API (https://learn.microsoft.com/en-us/bingmaps/rest-services/routes/calculate-a-distance-matrix) in my project. I have noticed that for some reason setting the "travelMode" field has no effect on the results and the values ALWAYS default to as if the field is set to 'driving'. I have tried the following three synchronous GET requests with one origin-destination pair; the only difference between the three is the travel mode set. This error also occurs with POST requests.

https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins=38.895608013295444,-77.03362316851509&destinations=38.8921643659989,-77.03289966239589&distanceUnit=km&timeUnit=second&travelMode=driving&key=BING_KEY

https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins=38.895608013295444,-77.03362316851509&destinations=38.8921643659989,-77.03289966239589&distanceUnit=km&timeUnit=second&travelMode=walking&key=BING_KEY

https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?origins=38.895608013295444,-77.03362316851509&destinations=38.8921643659989,-77.03289966239589&distanceUnit=km&timeUnit=second&travelMode=transit&key=BING_KEY

The respective results are:

{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http://dev.virtualearth.net/Branding/logo_powered_by.png","copyright":"Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"DistanceMatrix:http://schemas.microsoft.com/search/local/ws/rest/v1","destinations":[{"latitude":38.8921643659989,"longitude":-77.032899662395891}],"origins":[{"latitude":38.895608013295444,"longitude":-77.033623168515092}],"results":[{"destinationIndex":0,"originIndex":0,"totalWalkDuration":0,"travelDistance":0.615,"travelDuration":115}]}]}],"statusCode":200,"statusDescription":"OK","traceId":"54c369965a0747dbae3d1c2e57f7775a|BN000021E1|0.0.0.0|BN0000185D"}

{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http://dev.virtualearth.net/Branding/logo_powered_by.png","copyright":"Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"DistanceMatrix:http://schemas.microsoft.com/search/local/ws/rest/v1","destinations":[{"latitude":38.8921643659989,"longitude":-77.032899662395891}],"origins":[{"latitude":38.895608013295444,"longitude":-77.033623168515092}],"results":[{"destinationIndex":0,"originIndex":0,"totalWalkDuration":0,"travelDistance":0.615,"travelDuration":115}]}]}],"statusCode":200,"statusDescription":"OK","traceId":"31072cc10f344c4cae43894932dbbee3|BN000021CC|0.0.0.0|BN0000185E"}

{"authenticationResultCode":"ValidCredentials","brandLogoUri":"http://dev.virtualearth.net/Branding/logo_powered_by.png","copyright":"Copyright © 2021 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.","resourceSets":[{"estimatedTotal":1,"resources":[{"__type":"DistanceMatrix:http://schemas.microsoft.com/search/local/ws/rest/v1","destinations":[{"latitude":38.8921643659989,"longitude":-77.032899662395891}],"origins":[{"latitude":38.895608013295444,"longitude":-77.033623168515092}],"results":[{"destinationIndex":0,"originIndex":0,"totalWalkDuration":0,"travelDistance":0.615,"travelDuration":115}]}]}],"statusCode":200,"statusDescription":"OK","traceId":"fca1dedc8b5c41048c7aa86f12a6a492|BN000021CC|0.0.0.0|BN0000185E"}

As you can see, the travelDistance and travelDuration values are the same for all three. If you check the coordinates on Bing Maps, you will see this these values correspond to driving (walking should be around 0.3 km and 4 min.). Any help would be greatly appreciated as it has taken days for me to narrow down this issue in my code.

Thank you!

PS @IoTGirl I saw you answer some similar questions about the Distance Matrix API previously. Perhaps you are the correct person I should be talking to? Thanks!

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
592 questions
Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
245 questions
{count} votes

Accepted answer
  1. kdglider8 106 Reputation points
    2021-03-20T04:04:51.207+00:00

    This question is answered at this link: https://answers.microsoft.com/en-us/bing/forum/all/bing-maps-api-distance-matrix-travel-mode-is/7bcd61ab-29a1-4275-b468-fd699d0ac18d.

    Providing it for future viewers of this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. António Sérgio Azevedo 7,666 Reputation points Microsoft Employee
    2021-03-20T08:14:07.327+00:00

    Thank you @kdglider8 for confirming :).

    Let me add that we also fixed this bug and now you shouldn't get a 200 OK if you do not provide a matrix of coordinates with at least four(4) lat lon pairs for the smallest call.

    ----------

    For consistency let me post the answer provided https://answers.microsoft.com/en-us/bing/forum/all/bing-maps-api-distance-matrix-travel-mode-is/7bcd61ab-29a1-4275-b468-fd699d0ac18d here as well:

    "
    Distance Matrix is not designed for a single origin and destination pair but rather a matrix of coordinates so you need at least four(4) lat lon pairs for the smallest call. Please note that the Distance Matrix parameters are plural, "Origins" and "Destinations". You should be using the Routes API for a single route with two (2) waypoints. See Calculate a Route - Bing Maps | Microsoft Learn.

    Walking:

    http://dev.virtualearth.net/REST/V1/**Routes/Walking**?wp.0=38.895608013295444,-77.03362316851509&wp.1=38.8921643659989,-77.03289966239589&optmz=distance&output=xml&key=BingMapsKey

    Driving:

    http://dev.virtualearth.net/REST/V1/**Routes/Driving**?wp.0=38.895608013295444,-77.03362316851509&wp.1=38.8921643659989,-77.03289966239589&optmz=distance&output=xml&key=BingMapsKey

    Transit:

    http://dev.virtualearth.net/REST/V1/**Routes/Transit**?wp.0=38.895608013295444,-77.03362316851509&wp.1=38.8921643659989,-77.03289966239589&optmz=distance&output=xml&key=BingMapsKey

    These should get you the different routes and values you are looking for.

    For a better understanding of Bing Maps Transactions all up, take a look at Understanding Bing Maps Transactions - Bing Maps | Microsoft Learn. Specifically for this question the REST Routes and Routes-Distance Matrix.
    "

    1 person found this answer helpful.
    0 comments No comments