none
DistanceMatrix not working in South African CBD RRS feed

  • Question

  • Hi there

    I was trying Bing maps: DistanceMatrix and I keep getting an error response:

    {
        "authenticationResultCode""ValidCredentials",
        "brandLogoUri""http://dev.virtualearth.net/Branding/logo_powered_by.png",
        "copyright""Copyright © 2020 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"-25.751678,
                                "longitude"28.203422
                            }
                        ],
                        "errorMessage""Request completed but some pairs could not be processed.",
                        "origins": [
                            {
                                "latitude"-25.745126,
                                "longitude"28.196105
                            }
                        ],
                        "results": [
                            {
                                "destinationIndex"0,
                                "originIndex"0,
                                "totalWalkDuration"0,
                                "travelDistance"-1,
                                "travelDuration"-1
                            }
                        ]
                    }
                ]
            }
        ],
        "statusCode"200,
        "statusDescription""OK",
        "traceId""4ef5d01527d74e09b82c9c8f2da94924|DU00000D65|0.0.0.0|DU000005EB, DU00001AD9"

    }

    My code bellow

    var data = JSON.stringify({"origins":[{"latitude":-25.745126,"longitude":28.196105}],"destinations":[{"latitude":-25.751678,"longitude":28.203422}],"travelMode":"driving","distanceUnit":"km","timeUnit":"minute"});
    var xhr = new XMLHttpRequest();
    xhr.withCredentials = true;
    xhr.addEventListener("readystatechange"function() {
      if(this.readyState === 4) {
        console.log(this.responseText);
      }
    });
    xhr.open("POST""https://dev.virtualearth.net/REST/v1/Routes/DistanceMatrix?key=YOURKEY");
    xhr.setRequestHeader("Content-Type""application/json");

    xhr.send(data);

    With the same code above but different coordinates in America it works

    Origin: 40.707468, -73.796375
    Destination: 40.704812, -73.814163

    Can someone please explain to me, why it does not work in South African? Because https://docs.microsoft.com/en-us/bingmaps/coverage/geographic-coverage

    states there is good coverage.

    Thursday, June 25, 2020 9:06 PM

All replies