Skip to main content

Posts

Showing posts from December, 2015

Get address from Google Map API JSON response through Latitude and Longitude in C#

In this article I will explain how to get address of a location from help of geographical position coordinate Latitude and Longitude using Google Map API JSON response in C#. We need to implement two namespace in our C# code using System . Net ; using System . Web . Script . Serialization ; When we pass parameter i.e. Latitude and Longitude to our function that will return address of that location. public string getAddress ( string lat , string lng ) { string returnVal = string . Empty ; string url = string . Format ( "http://maps.googleapis.com/maps/api/geocode/json?latlng={0},{1}" , lat , lng ); using ( WebClient client = new WebClient ()) { string json = client . DownloadString ( url ); GoogleResponseData addressInfo = ( new JavaScriptSerializer ()). Deserialize < GoogleResponseData >( json ); returnVal = addressInfo . results [ 0 ]. formatted_address ; } return returnVal ; } Wh