Skip to content

exceptionless/Geocoding.net

 
 

Repository files navigation

Generic C# Geocoding API CI CodeQL

Includes a model and interface for communicating with current geocoding providers.

This repository is the actively maintained Geocoding.net fork for current provider integrations and compatibility work.

Provider Package Status Auth Notes
Google Maps Geocoding.Google Supported API key or signed client credentials BusinessKey remains available as a legacy signed-client compatibility path.
Azure Maps Geocoding.Microsoft Supported Azure Maps subscription key Primary Microsoft-backed geocoder.
Bing Maps Geocoding.Microsoft Deprecated compatibility Bing Maps enterprise key BingMapsGeocoder remains available for existing consumers and is marked obsolete for new development.
HERE Geocoding and Search Geocoding.Here Supported HERE API key Uses the current HERE Geocoding and Search API.
MapQuest Geocoding.MapQuest Supported API key Commercial API only. OpenStreetMap mode is no longer supported.
Yahoo PlaceFinder/BOSS Geocoding.Yahoo Deprecated OAuth consumer key + secret Legacy package retained for compatibility, but the service remains deprecated and unverified.

The API returns latitude/longitude coordinates and normalized address information. This can be used to perform address validation, real time mapping of user-entered addresses, distance calculations, and much more.

See latest release notes.

⚠️ MapQuest OpenStreetMap mode was tied to a retired service surface and now fails fast instead of silently calling dead endpoints.

Installation

Install via nuget:

Install-Package Geocoding.Core

and then choose which provider you want to install (or install all of them):

Install-Package Geocoding.Google
Install-Package Geocoding.MapQuest
Install-Package Geocoding.Microsoft
Install-Package Geocoding.Here

If you still need the deprecated Yahoo compatibility package, install Geocoding.Yahoo explicitly and plan to remove it before the next major version.

Example Usage

Simple Example

IGeocoder geocoder = new GoogleGeocoder() { ApiKey = "this-is-my-google-api-key" };
IEnumerable<Address> addresses = await geocoder.GeocodeAsync("1600 pennsylvania ave washington dc");
Console.WriteLine("Formatted: " + addresses.First().FormattedAddress); //Formatted: 1600 Pennsylvania Ave SE, Washington, DC 20003, USA
Console.WriteLine("Coordinates: " + addresses.First().Coordinates.Latitude + ", " + addresses.First().Coordinates.Longitude); //Coordinates: 38.8791981, -76.9818437

It can also be used to return address information from latitude/longitude coordinates (aka reverse geocoding):

IGeocoder geocoder = new AzureMapsGeocoder("this-is-my-azure-maps-key");
IEnumerable<Address> addresses = await geocoder.ReverseGeocodeAsync(38.8976777, -77.036517);

Using Provider-Specific Data

GoogleGeocoder geocoder = new GoogleGeocoder();
IEnumerable<GoogleAddress> addresses = await geocoder.GeocodeAsync("1600 pennsylvania ave washington dc");

var country = addresses.Where(a => !a.IsPartialMatch).Select(a => a[GoogleAddressType.Country]).First();
Console.WriteLine("Country: " + country.LongName + ", " + country.ShortName); //Country: United States, US

The Microsoft providers expose AzureMapsAddress, and the legacy BingMapsGeocoder / BingAddress surface remains available as an obsolete compatibility layer. The Yahoo package also remains deprecated and should only be used for compatibility scenarios.

API Keys

Google uses a Geocoding API key, and many environments now require one for reliable access.

If you still depend on signed Google Maps client credentials, BusinessKey remains available as a legacy compatibility option.

Azure Maps requires an Azure Maps account key.

Bing Maps requires an existing Bing Maps enterprise key. The provider is deprecated and retained only for compatibility during migration to Azure Maps.

MapQuest requires a developer API key.

HERE supports a HERE API key for the current Geocoding and Search API.

The current major-version line no longer supports HERE app_id/app_code credentials. Migrate existing HERE integrations to API keys before upgrading.

Yahoo still uses the legacy OAuth consumer key and consumer secret flow, but onboarding remains unverified and the package is deprecated.

How to Build from Source

dotnet restore
dotnet build

For a nice experience, use Visual Studio Code to work with the project. The editor is cross platform and open source.

Alternatively, if you are on Windows, you can open the solution in Visual Studio and build.

Service Tests

You will need credentials for each respective service to run the service tests. Make a settings-override.json as a copy of settings.json in the test project and put in your provider credentials there. Then you should be able to run the tests.

Most provider-backed integration tests skip with a message indicating which setting is required when credentials are missing. The Yahoo suite now follows the same credential gating, but the provider remains deprecated and unverified.

Provider-specific tests stay at the root of test/Geocoding.Tests with provider-prefixed filenames. Shared cross-cutting areas use focused folders such as Models, Serialization, Extensions, and Utility.

Provider-specific automated coverage exists for Google, Microsoft (Azure Maps and Bing compatibility), HERE, MapQuest, and Yahoo compatibility, alongside shared core behavior tests.

See the docs site in docs/ for the provider guides, onboarding material, and sample app usage notes.

Sample App

The sample app in samples/Example.Web is an ASP.NET Core 10 minimal API that can geocode and reverse geocode against any configured provider, including the deprecated Bing compatibility option when explicitly enabled. Yahoo remains excluded from the sample because the underlying Yahoo PlaceFinder/BOSS APIs are deprecated/discontinued and the Geocoding.Yahoo provider is retained for compatibility only.

dotnet run --project samples/Example.Web/Example.Web.csproj

Configure a provider in samples/Example.Web/appsettings.json or via environment variables such as Providers__Azure__ApiKey, Providers__Bing__ApiKey, Providers__Google__ApiKey, Providers__Here__ApiKey, or Providers__MapQuest__ApiKey. Once the app is running, use samples/Example.Web/sample.http to call /providers, /geocode, and /reverse.

About

C# GeoCoding / Address Validation API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 94.5%
  • PowerShell 5.5%