Wednesday, June 15, 2016

Xamarin / C#.NET Get Country Name from gps coordinate - offline

Needed this for one of my home projects.

Found a handy python implementation here - so I set about porting it over to C#

Github repo can be found here

The project is a portable class library - so should work just as well for your Xamarin projects.

Sample usage:

var service = new CountryReverseGeocodeService();
var angola = new GeoLocation { Latitude = 12.437329, Longitude = -4.895250 };
LocationInfo info = service.FindCountry(angola);

var alaska = new GeoLocation { Latitude = -170.333949, Longitude = 63.431027 };
LocationInfo info = _service.FindUsaState(alaska);

hope this spares someone else a few hours implementation ;)

Update:
Nuget available here