A simple wrapper for the Google geocoding service that's compatible with .NET Core. The library returns an instance of a Location class with the following properties: Latitude and Longitude. Default values for Latitude and Longitude is 0.
- nuget
- PM> Install-Package GoogleGeoCoderCore
- .NETStandard 1.6
- NETStandard.Library (>= 1.6.0)
- System.Xml.XmlDocument (>= 4.3.0)
- System.Xml.XPath.XmlDocument (>= 4.3.0)
- System.Net.Http (>= 4.3.0)
using GoogleGeoCoderCore;
public static async Task<Location> GetLocation(string address)
{
var geocoder = new GoogleGeocodeService();
var result = await geocoder.GeocodeLocation(address);
return result;
}
public static void Main(string[] args)
{
var location = GetLocation("Atlanta, GA");
Console.WriteLine(location.Result.Latitude);
Console.WriteLine(location.Result.Longitude);
Console.ReadLine();
}
Complete test class included.