WinRT获取坐标和当前的位置

来源:互联网 发布:淘宝买家秀在哪里看 编辑:程序博客网 时间:2024/05/22 15:30
Geolocator geoloc = new Geolocator();
            Geoposition position = await geoloc.GetGeopositionAsync();//h获得地理坐标
            HttpClient httpClient = new HttpClient();
            HttpResponseMessage httpResult = await httpClient.GetAsync(String.Format("http://maps.google.com/maps/api/geocode/xml?latlng={0},{1}&language=zh-CN&sensor=false", position.Coordinate.Latitude, position.Coordinate.Longitude));
            var resss = await httpResult.Content.ReadAsStringAsync();
            XmlDocument xml = new XmlDocument();
            xml.LoadXml(resss);
            var nr = xml.SelectNodes("GeocodeResponse").First();
            var v = nr.SelectNodes("result").OrderBy(d => 1).Skip(3).Take(1).ToList().First();
            var t = v.SelectNodes("formatted_address").First().InnerText;
0 0
原创粉丝点击