Oct 28 2018 12:09PM
Pranav
3315 Views
Get Google map geo point for an any pincode by using google map Api.
Before request an Google Map API for Geo point, it is required to create a google API Key.
Follow the below steps to create Google API Key
1) Go to the following link
https://developers.google.com/url-shortener/v1/getting_started#APIKey
2) Click on "GET A KEY" , Select or Create a new project.
3) Now Click on "Enable API". (Sample API Key : AIzaSyAvjD359ibDC-*****S8A73ZdTZ*****)
Now, You are ready to start developing with Google URL Shortener API.
public static string apiKey = "AIzaSyDnEtI****9i4FJIZ***";
protected void Page_Load(object sender, EventArgs e)
{
string latlng = GetLatLngByPincode("600101");
}
public string GetLatLngByPincode(string pincode)
{
string locationURL = "https://maps.googleapis.com/maps/api/geocode/json?address=" + pincode + "&key=" + apiKey;
string r = new System.Net.WebClient().DownloadString(locationURL);
dynamic result = JObject.Parse(r);
string latlng = result.results[0].geometry.location.lat + "," + result.results[0].geometry.location.lng;
return latlng;
}
Thanks, Hope this helps you to get geo points from pincode.
BackToTop