13,556,069 members
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

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
 OriginalGriff 350 0x01AA 270 Maciej Los 155 CPallini 118 Jochen Arndt 115
 OriginalGriff 5,814 ppolymorphe 2,452 Richard MacCutchan 2,402 Maciej Los 1,985 Wendelius 1,890