Last active
August 29, 2015 14:27
-
-
Save suchithm/e7bb13e0ccf6c82e992a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void FnGeoCodeApi() | |
{ | |
string strGeoCode = string.Format ("address={0}","Silicon Valley,CA,USA"); | |
string strGeoCodeFullURL = string.Format (Constants.strGeoCodingUrl,strGeoCode); | |
string strResult=await FnHttpRequest(strGeoCodeFullURL); | |
if ( strResult != Constants.strException ) | |
{ | |
var objGeoCodeClass= JsonConvert.DeserializeObject<GoogleGeoCodeClass> (strResult); | |
if ( objGeoCodeClass.status == "OK" ) | |
{ | |
var Position = new LatLng ( objGeoCodeClass.results [0].geometry.location.lat , objGeoCodeClass.results [0].geometry.location.lng ); | |
string address = objGeoCodeClass.results [0].formatted_address; | |
} | |
} | |
} | |
WebClient webclient; | |
async Task<string> FnHttpRequest(string strUri) | |
{ | |
webclient = new WebClient (); | |
string strResultData; | |
try | |
{ | |
strResultData= await webclient.DownloadStringTaskAsync (new Uri(strUri)); | |
Console.WriteLine(strResultData); | |
} | |
catch | |
{ | |
strResultData = Constants.strException; | |
} | |
finally | |
{ | |
if ( webclient!=null ) | |
{ | |
webclient.Dispose (); | |
webclient = null; | |
} | |
} | |
return strResultData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment