如何在c#.Please Help
中使用纬度和经度获取位置地址答案 0 :(得分:7)
试试这段代码,我希望这会对你有帮助。
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();
}
答案 1 :(得分:1)