win8 获得地理坐标

using Windows.Devices.Geolocation; 
Geolocator geoloc = new Geolocator(); Geoposition position = await geoloc.GetGeopositionAsync();//h获得地理坐标
            HttpClient httpClient = new HttpClient();
            httpClient.BaseAddress = new Uri("http://nominatim.openstreetmap.org");
            HttpResponseMessage httpResult = await httpClient.GetAsync(String.Format("reverse?format=json&lat={0}&lon={1}", position.Coordinate.Latitude, position.Coordinate.Longitude));

            JsonObject jsonObject = JsonObject.Parse(await httpResult.Content.ReadAsStringAsync());
            return jsonObject.GetNamedObject("address").GetNamedString("road") + DateTime.Now.ToString("' ('HH:mm:ss')'");

将返回的地理坐标传给

http://nominatim.openstreetmap.org 这个网站,,这个网站会返回一个josn对象, josn 对象里面包含地址信息

总结:上面的代码就是将win8 平板获得的坐标传给一个网站,然后返回一个地址信息。

posted on 2012-09-03 16:25  GIS-MAN  阅读(370)  评论(0编辑  收藏  举报

导航