We need to install GoogleMaps.LocationServices from the NuGet package. It uses Google's REST API to get lat/long for a given address. Using these you can get latitude and longitude without any need of any API Key.
To install GoogleMaps.LocationServices, either, run the following command in the Package Manger Console.
PM> Install-Package GoogleMaps.LocationServices
Or, search it on Nuget and install it directly
After Install the above package you can use it like this:
Firstly, Add the NameSpace.
using GoogleMaps.LocationServices;
Then use GoogleLocationService() class to get the latitude and longitude of any given address.
Example:
/// <summary>
/// This is to get the lat long from address
/// </summary>
public void GetLatLongFromAddress()
{
var address = "920 N. Parish Place, Burbank, CA 91506";
var locationService = new GoogleLocationService();
var point = locationService.GetLatLongFromAddress(address);
var latitude = point.Latitude;
var longitude = point.Longitude;
}
Enjoyyy.... :)
To install GoogleMaps.LocationServices, either, run the following command in the Package Manger Console.
PM> Install-Package GoogleMaps.LocationServices
Or, search it on Nuget and install it directly
After Install the above package you can use it like this:
Firstly, Add the NameSpace.
using GoogleMaps.LocationServices;
Then use GoogleLocationService() class to get the latitude and longitude of any given address.
Example:
/// <summary>
/// This is to get the lat long from address
/// </summary>
public void GetLatLongFromAddress()
{
var address = "920 N. Parish Place, Burbank, CA 91506";
var locationService = new GoogleLocationService();
var point = locationService.GetLatLongFromAddress(address);
var latitude = point.Latitude;
var longitude = point.Longitude;
}
Enjoyyy.... :)
5 comments:
thank to all members,,,especially Abhinav Ranjan Sinha. . . very thankful . . .i appreciate your effort to help others
Thanks Praveen...
Excellent tutorial. Just to the point. Many thanks.
GetLatLongFromAddress is returning null for an valid address.
Am I missing something ?
Thank you verry much!
Post a Comment