Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The calculation below is based upon a calculation found on StackOverflow:
- // http://stackoverflow.com/a/11172685
- // This code runs on an Azure WebService and I have found no way to use GeoCoordinate to access the GetDistanceTo method,
- // which is why I've tried to solve it this way.
- // Calculation starts here
- var R = 6378.137; // Radius of Earth in KM
- var dLat = (Marker.Lat - Lat) * Math.PI / 180;
- var dLng = (Marker.Lng - Long) * Math.PI / 180;
- var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
- Math.Cos(Marker.Lat * Math.PI / 180) * Math.Cos(Lat * Math.PI / 180) *
- Math.Sin(dLng / 2) * Math.Sin(dLng / 2);
- var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
- var d = R * c * 1000; // d = the distance in meters;
- // Calculation ends here
- if (d <= Distance) // if the calculated distance (d) is less or equal to Distance it should be included in the results.
- {
- FinalMarkers.Add(Marker);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement