【发布时间】:2015-05-21 13:40:52
【问题描述】:
如何从 Windows Phone 8.1 获取当前国家/地区位置以及可能的 CountryCode?我这样做了,但 FindLocationsAsync 向我抛出异常“值不在预期范围内”
private async void LocateMe()
{
Geolocator GeoLoc = new Geolocator();
GeoLoc.DesiredAccuracyInMeters = 50;
try
{
Geoposition GeoPosition = await GeoLoc.GetGeopositionAsync();
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync("", GeoPosition.Coordinate.Point, 5);
if (result.Status == MapLocationFinderStatus.Success)
{
foreach (MapLocation mapLocation in result.Locations)
{
string strCountryCode = mapLocation.Address.CountryCode;
}
}
}
catch(Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
}
}
【问题讨论】:
标签: c# .net geolocation windows-phone-8.1 windows-8.1