C# 使用Windows Phone地图获取附近的位置

C# 使用Windows Phone地图获取附近的位置,c#,location,windows-phone,maps,here-api,C#,Location,Windows Phone,Maps,Here Api,我正试图通过地理定位服务和WindowsPhone8的地图服务找到当前位置附近的城镇。我已经在很多网站上搜索过了,但是我没有找到任何关于WP8的内容,我也不知道怎么做 这可以通过WP8 SDK完成吗?我是否需要使用外部服务 提前感谢是的,您可以在中使用ReverseGeocodeQuery类获取当前地址(您案例中的城镇)。首先,尝试按如下方式获取当前坐标: Geolocator geolocator = new Geolocator(); geolocator.DesiredAccur

我正试图通过地理定位服务和WindowsPhone8的地图服务找到当前位置附近的城镇。我已经在很多网站上搜索过了,但是我没有找到任何关于WP8的内容,我也不知道怎么做

这可以通过WP8 SDK完成吗?我是否需要使用外部服务


提前感谢

是的,您可以在中使用
ReverseGeocodeQuery
类获取当前地址(您案例中的城镇)。首先,尝试按如下方式获取当前坐标:

Geolocator geolocator = new Geolocator();     
geolocator.DesiredAccuracyInMeters = 100; 
Geoposition geoposition = await geolocator.GetGeopositionAsync(
                         maximumAge: TimeSpan.FromMinutes(5),
                         timeout: TimeSpan.FromSeconds(5));
然后,使用坐标查询地址:

ReverseGeocodeQuery query = new ReverseGeocodeQuery();
query.GeoCoordinate = new GeoCoordinate(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
query.QueryCompleted += (s, ev) =>
{
   if (ev.Error == null && ev.Result.Count > 0)
   {
       List<MapLocation> locations = ev.Result as List<MapLocation>;
       // do what you want with the locations...
   }
}
query.QueryAsync();
ReverseGeocodeQuery=new ReverseGeocodeQuery();
query.geocordinate=新的地理坐标(geoposition.Coordinate.Latitude、geoposition.Coordinate.Longitude);
query.QueryCompleted+=(s,ev)=>
{
如果(ev.Error==null&&ev.Result.Count>0)
{
列表位置=ev。结果为列表;
//对这些位置做你想做的。。。
}
}
query.QueryAsync();

可以找到更详细的示例。

非常有效。谢谢