12,512,686 members (26,419 online)
Rate this:
See more:
Hi,
I am developing a Windows 8 App. I have a requirement to find the shortest distance between two locations by road using bing maps. How to do that?

Thanks,
Kalai
Posted 11-Oct-12 0:00am
kalai91216

Rate this:

## Solution 1

Hi Kalai91

try this to calculate distance b/w tow places in window 8 App

```private double CalculateDistance(double prevLat, double prevLong, double currLat, double currLong)
{
const double degreesToRadians = (Math.PI / 180.0);
const double earthRadius = 6371; // kilometers

// convert latitude and longitude values to radians

// calculate radian delta between each position.

// calculate distance
var expr1 = (Math.Sin(radDeltaLat / 2.0) *

var expr2 = 2.0 * Math.Atan2(Math.Sqrt(expr1),
Math.Sqrt(1 - expr1));

var distance = (earthRadius * expr2);
return distance * 1000;  // return results as meters
}```
v2

Top Experts
Last 24hrsThis month
 Maciej Los 160 ppolymorphe 85 OriginalGriff 65 manu_dhobale 60 Suvendu Shekhar Giri 55
 Maciej Los 90 manu_dhobale 60 Suvendu Shekhar Giri 55 OriginalGriff 45 Karthik Bangalore 25