System.Device.Location.GeoLocation
Posted
by Aligned
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Aligned
Published on Wed, 26 Jun 2013 04:30:36 GMT
Indexed on
2013/06/26
22:22 UTC
Read the original article
Hit count: 146
Originally posted on: http://geekswithblogs.net/Aligned/archive/2013/06/26/system.device.location.geolocation.aspx
A co-worker (Scott) sent out this email and it was so good I asked him if I could share it with all of you. I changed the latitude and longitude to random locations to protect the innocent.
“Stumbled across this method this morning while coding all the math out by hand to calculate distances. This one is definitely worth filing away for future reference, saved me a ton of work. This was added in v4 of the framework, and is in the core framework install, so should work in services as well as client applications.
var location1 = new GeoCoordinate(40.102, -94.788171); var location2 = new GeoCoordinate(50.0011, -96.699148); // distance shown is straight line meters. Console.WriteLine(location1.GetDistanceTo(location2)); Console.ReadKey();
© Geeks with Blogs or respective owner