且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Windows Phone 8 中使用纬度和经度获取位置

更新时间: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();

}