I want to retrieve Geo address from given latitude and longitude using geocoding,
using the given example on the site
http://maps.googleapis.com/maps/api/geocod
I have a simple solution that works for the Google Geocode JSON results. It is a simple for loop that returns that short and long version in a string array. Just call the function and provide the "types" in the argument.
string[] street_number = GetJSONValueBasedOnType(record.geocode, "street_number");
public string[] GetJSONValueBasedOnType(NewGoogleGeocode gc, string WhatYouWant)
{
string[] returns = new string[2];
returns[0] = string.Empty;
returns[1] = string.Empty;
bool isInIt;
foreach (var v in gc.results[0].address_components)
{
isInIt = false;
foreach (var t in v.types)
{
if (t == WhatYouWant)
{
isInIt = true;
}
}
if (isInIt)
{
returns[0] = v.short_name;
returns[1] = v.long_name;
}
}
return returns;
}