# Distance Matrix Parallel Distances

• ### Question

• Hello,

I have recently created a visual basic macro that allows me to generate a distance matrix for select coordinate arrays. It works perfectly and I was impressed by the speed and efficiency of the Bing maps API!

However, I noticed that all results were parallel. The travel distance and duration from location X to location Y was exactly the same as when travelling from location Y to location X. Within a matrix of nearly 200 origins and destinations (~ 35 000 entries), all but 20 values were parallel.

However, upon checking with the Bing maps service, these values were never parallel.

Is there a way to solve this?

I am making a synchronous HTTP POST request, with Travel mode set to driving, and with header and body set according to the Distance Matrix documentation

Below a fraction of the generated distance matrix

 jl1 jl2 jl3 jl4 jl5 jl6 jl7 jl1 0 160,021 162,7377 227,6854 899,5618 147,2492 129,3246 jl2 160,021 0 24,00036 96,17511 1053,769 15,99183 57,19422 jl3 162,7377 24,00036 0 116,1118 1048,165 30,86553 39,30592 jl4 227,6854 96,17511 116,1118 0 1121,441 93,49228 152,0717 jl5 899,5618 1053,769 1048,165 1121,441 0 1040,998 1011,119 jl6 147,2492 15,99183 30,86553 93,49228 1040,998 0 60,90539 jl7 129,3246 57,19422 39,30592 152,0717 1011,119 60,90539 0

• Edited by Friday, June 15, 2018 8:04 AM
Friday, June 15, 2018 7:47 AM

### All replies

• Hi,

We also have requirement to generate Distance matrix. Suppose we want to generate 10 * 10 matrix  is it possible using Distance matrix using javascript.

Anyone have sample code (java script) of Distance matrix. Also sample code to get the optimized route using distance matrix may be similar to Traveling salesman problem.

Thanks!

Balasaheb

Thursday, June 21, 2018 1:22 PM
• Hi,

Any update for the same

Thanks!

Balasaheb

Saturday, June 23, 2018 6:21 PM
• The distance matrix service is a REST service and can be accessed from any programming language that can connect to the internet. Here is a JavaScript sample: http://bingmapsv8samples.azurewebsites.net/#Distance%20Matrix%20Service%20-%20POST

There is a .NET code sample for calculating travelling salesmen from distance matrix that can be converted to JavaScript here:

That said, you may want to consider the Azure Maps API which provides travelling salesmen optimized routing right in their routing service: https://docs.microsoft.com/en-us/rest/api/maps/route/getroutedirections Use the computeBestOrder parameter. Here is a JavaScript code sample: https://azuremapscodesamples.azurewebsites.net/default.aspx#Waypoint%20Optimization

Monday, June 25, 2018 4:11 PM