更新时间:2023-11-10 15:15:46
试试这个代码,希望对你有帮助.
try this code ,I hope this will help you.
WebClient client = new WebClient();
string strLatitude = " 13.00";
string strLongitude = "80.25";
client.DownloadStringCompleted += client_DownloadStringCompleted;
string Url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=" + strLatitude + "," + strLongitude + "&sensor=true";
client.DownloadStringAsync(new Uri(Url, UriKind.RelativeOrAbsolute));
Console.Read();
static void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
var getResult = e.Result;
JObject parseJson = JObject.Parse(getResult);
var getJsonres = parseJson["results"][0];
var getJson = getJsonres["address_components"][1];
var getAddress = getJson["long_name"];
string Address = getAddress.ToString();
}