https://github.com/sethwebster/googlemaps.locationservices
A simple library (including Nuget Package) for Google Maps geolocation and reverse geolocation
https://github.com/sethwebster/googlemaps.locationservices
Last synced: 11 months ago
JSON representation
A simple library (including Nuget Package) for Google Maps geolocation and reverse geolocation
- Host: GitHub
- URL: https://github.com/sethwebster/googlemaps.locationservices
- Owner: sethwebster
- Created: 2011-08-24T21:45:42.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2020-04-14T23:58:49.000Z (about 6 years ago)
- Last Synced: 2025-03-12T12:46:26.456Z (over 1 year ago)
- Language: C#
- Homepage: http://nuget.org/List/Packages/GoogleMaps.LocationServices
- Size: 349 KB
- Stars: 45
- Watchers: 8
- Forks: 42
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GoogleMaps.LocationServices
=======================================
A simple library for Google Maps geolocation and reverse geolocation.
The easiest way to get hold of it is to install the [Nuget package](http://nuget.org/List/Packages/GoogleMaps.LocationServices).
From the package manager console:
`PM> Install-Package GoogleMaps.LocationServices`
Example Lookup
----------------------
```C#
using GoogleMaps.LocationServices;
.....
AddressData[] addresses = new AddressData[]
{
new AddressData // Belgium
{
Address = "Rue du Cornet 6",
City = "VERVIERS",
State = null,
Country = "Belgium",
Zip = "B-4800"
},
new AddressData
{
Address = "1600 Pennsylvania ave",
City = "Washington",
State = "DC"
},
new AddressData
{
Address = "407 N Maple Dr. #1",
City = "Beverly Hills",
State = "CA"
}
};
// Constructor has 3 overload
// No parameters. It does not use API Key
var gls = new GoogleLocationService();
// Boolean parameter to force the requests to use https
// var gls = new GoogleLocationService(useHttps: true);
// String paremeter that provides the google map api key
// var gls = new GoogleLocationService(apikey: "YOUR API KEY");
foreach (var address in addresses)
{
try
{
var latlong = gls.GetLatLongFromAddress(address);
var Latitude = latlong.Latitude;
var Longitude = latlong.Longitude;
System.Console.WriteLine("Address ({0}) is at {1},{2}", address, Latitude, Longitude);
}
catch(System.Net.WebException ex)
{
System.Console.WriteLine("Google Maps API Error {0}", ex.Message);
}
}
```