GeoCoordinate location = watcher.Position.Location;
if (location.IsUnknown)
return;
Console.WriteLine("Time: {0}", e.Position.Timestamp);
Console.WriteLine("Longitude: {0}", location.Longitude); //經度
Console.WriteLine("Latitude: {0}", location.Latitude); //緯度
Console.WriteLine("Altitude: {0}", location.Altitude); //高度
Console.WriteLine("Course: {0}", location.Course); //角度
Console.WriteLine("Speed: {0}", location.Speed); //速度
CivicAddressResolver resolver = new CivicAddressResolver();
CivicAddress realLocation = m_addressResolver.ResolveAddress(location);
if (realLocation.IsUnknown)
return;
Console.WriteLine("Address1: {0}", realLocation.AddressLine1); //實際地址
Console.WriteLine("Address2: {0}", realLocation.AddressLine2);
Console.WriteLine("Building: {0}", realLocation.Building); //門牌號碼
Console.WriteLine("City: {0}", realLocation.City); //縣市
Console.WriteLine("CountryRegion: {0}", realLocation.CountryRegion); //國家
Console.WriteLine("PostalCode: {0}", realLocation.PostalCode); //郵遞區號
Console.WriteLine("StateProvince: {0}", realLocation.StateProvince); //省份
Console.WriteLine("FloorLevel: {0}", realLocation.FloorLevel); //樓層
}</pre></div>
static CivicAddressResolver m_addressResolver = new CivicAddressResolver();
static void watch_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
var location = e.Position.Location;
Console.WriteLine("Time: {0}", e.Position.Timestamp);
Console.WriteLine("Longitude: {0}", location.Longitude); //經度
Console.WriteLine("Latitude: {0}", location.Latitude); //緯度
Console.WriteLine("Altitude: {0}", location.Altitude); //高度
Console.WriteLine("Course: {0}", location.Course); //角度
Console.WriteLine("Speed: {0}", location.Speed); //速度
var realLocation = m_addressResolver.ResolveAddress(location);
Console.WriteLine("Address1: {0}", realLocation.AddressLine1); //實際地址
Console.WriteLine("Address2: {0}", realLocation.AddressLine2);
Console.WriteLine("Building: {0}", realLocation.Building); //門牌號碼
Console.WriteLine("City: {0}", realLocation.City); //縣市
Console.WriteLine("CountryRegion: {0}", realLocation.CountryRegion); //國家
Console.WriteLine("PostalCode: {0}", realLocation.PostalCode); //郵遞區號
Console.WriteLine("StateProvince: {0}", realLocation.StateProvince); //省份
Console.WriteLine("FloorLevel: {0}", realLocation.FloorLevel); //樓層
Console.WriteLine();
}</pre></div>