How to calculate the driving distance between two

2019-09-12 05:17发布

In my app I am getting the latitude , longitude co-ordinates of places using GeocodeService now I want to get distance between these places.

I've tried GetDistanceTo method to get the distance two location co-ordinates but it gives me stright distance.

How can I calculate driving distance between two locations?

thanks in advance

1条回答
倾城 Initia
2楼-- · 2019-09-12 05:37

To calculate the driving distance you'll have to use the Bing Routes API (or Google, but I assume you're using Bing Maps).

There's an example of using the api to find a driving route between two places here: http://msdn.microsoft.com/en-us/library/gg636957.aspx

The general call is: http://dev.virtualearth.net/REST/V1/Routes/Driving?o=xml&wp.0=location1&wp.1=location2&avoid=minimizeTolls&key=BingMapsKey

You'll have to register for a Bing Maps API key, and then replace location1 and location2 with the locations you like.

The distance should be returned in travelDistance in the json or xml

查看更多
登录 后发表回答