question

KevinDong-4534 avatar image
0 Votes"
KevinDong-4534 asked ·

Bing Maps API Distance Matrix Travel Mode is ALWAYS driving

Hi,


I'm on a Basic Education license for the Bing Maps REST services, and I'm using the Distance Matrix API (https://docs.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-mapswindows-maps
· 3
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KevinDong-4534 thank you for sharing your research and the issues you found when using Distance Matrix API: https://docs.microsoft.com/en-us/bingmaps/rest-services/routes/calculate-a-distance-matrix?

In the doc above we can see there are some Geographic constraints when using travelMode , though I believe all your tests are within North America, can you confirm?

78810-image.png

Thank you!


0 Votes 0 ·
image.png (101.8 KiB)

@asergaz Thank you for your reply! Yes I have reviewed the Distance Matrix documentation and am aware of the geographic constraints. My queries, including the test cases that I have listed above, are indeed all in North America; Washington DC to be exact. Thus, I believe the different travel modes should be available to me.

1 Vote 1 ·
IoTGirl avatar image IoTGirl KevinDong-4534 ·
1 Vote 1 ·
KevinDong-4534 avatar image
1 Vote"
KevinDong-4534 answered ·

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 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@KevinDong-4534 Thank you for marking the answer as "accepted".

0 Votes 0 ·
asergaz avatar image
1 Vote"
asergaz answered ·

Thank you @KevinDong-4534 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 Docs.

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 Docs. Specifically for this question the REST Routes and Routes-Distance Matrix.
"




·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.