Component: Google Geocoder
Version 1.1 (December 2008) - open source - C# & NET 3.5
The ScipBe.Common.Geocoding namespace contains the GoogleGeoCoder class. This class uses the Google Maps Geocoding HTTP REST service to retrieve geographical data like the latitude and longitude of a given address.
Check out one of my articles where I describe the implementation of this GoogleGeoCoder class.
Class diagram:

C# examples:
GoogleGeoCoder geoCoder = new GoogleGeoCoder("A Google Maps API key");
IGeoData geoData = geoCoder.GetGeoData("Street City Country");
if (geoData.Status == GeoStatusCode.Success)
{
Console.WriteLine(geoData.Accuracy);
Console.WriteLine("{0}:{1}", geoData.Coordinate.Longitude, geoData.Coordinate.Latitude);
}
GoogleGeoCoder geoCoder = new GoogleGeoCoder("A Google Maps API key");
IGeoData geoData = geoCoder.GetGeoData("Street City Country");
if (geoData.Status == GeoStatusCode.Success)
{
Console.WriteLine(geoData.Accuracy);
Console.WriteLine("Address = {0}", geoData.Address);
Console.WriteLine("Thoroughfare = {0}", geoData.ThoroughfareName);
Console.WriteLine("Locality = {0}", geoData.DependentLocalityName);
Console.WriteLine("Administrative area = {0}", geoData.AdministrativeAreaName);
Console.WriteLine("Country = {0}", geoData.CountryNameCode);
Console.WriteLine("{0}:{1}", geoData.Coordinate.Longitude, geoData.Coordinate.Latitude);
}
GoogleGeoCoder geoCoder = new GoogleGeoCoder("A Google Maps API key");
geoCoder.GeoListCompleted += new GeoListCompletedEventHandler(geoCoder_GeoListCompleted);
geoCoder.GetGeoListAsync("Street City Country");
void geoCoder_GeoListCompleted(object sender, IEnumerable<IGeoData> geoList)
{
if ((geoList.Count() > 0) && (geoList.First().Status == GeoStatusCode.Success))
{
foreach (var geoData in geoList)
{
Console.WriteLine("Address = {0}", geoData.Address);
Console.WriteLine("Country = {0}", geoData.CountryNameCode);
Console.WriteLine("Coordinates = {0}:{1}", geoData.Coordinate.Longitude, geoData.Coordinate.Latitude);
}
}
}
Copyrights and distribution
- These components are open source (Mozilla Public License 1.1) and may be freely distributed.
- The author doesn't give a warranty for error free running of these components and he doesn't give any support.
- See source code and help file for more information about the classes, interfaces, properties, methods, events, ...
Download
Google Geocoder
- Contents: Components with sources and help file (C#, .NET 3.5, Visual Studio 2008)
- Version: 1.1 (2008-12-20)
- Author: Stefan Cruysberghs