CivicAddress.IsUnknown 属性
定义
获取一个值,该值指示 CivicAddress 是否包含数据。Gets a value that indicates whether the CivicAddress contains data.
public:
property bool IsUnknown { bool get(); };
public bool IsUnknown { get; }
member this.IsUnknown : bool
Public ReadOnly Property IsUnknown As Boolean
属性值
如果 CivicAddress 等于 Unknown,则为 true;否则为 false。true if the CivicAddress is equal to Unknown; otherwise, false.
示例
下面的示例使用 IsUnknown 来检查 CivicAddress 从 ResolveAddress 市政地址输出之前返回的。The following example uses IsUnknown to check the CivicAddress that is returned from ResolveAddress before the civic address is printed out.
static void ResolveAddressSync()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 1.0; // set to one meter
watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
CivicAddressResolver resolver = new CivicAddressResolver();
if (watcher.Position.Location.IsUnknown == false)
{
CivicAddress address = resolver.ResolveAddress(watcher.Position.Location);
if (!address.IsUnknown)
{
Console.WriteLine("Country: {0}, Zip: {1}",
address.CountryRegion,
address.PostalCode);
}
else
{
Console.WriteLine("Address unknown.");
}
}
}
Public Sub ResolveAddressSync()
Dim watcher As GeoCoordinateWatcher
watcher = New System.Device.Location.GeoCoordinateWatcher(GeoPositionAccuracy.High)
Dim started As Boolean = False
watcher.MovementThreshold = 1.0 'set to one meter
started = watcher.TryStart(False, TimeSpan.FromMilliseconds(1000))
Dim resolver As CivicAddressResolver = New CivicAddressResolver()
If started Then
If Not watcher.Position.Location.IsUnknown Then
Dim address As CivicAddress = resolver.ResolveAddress(watcher.Position.Location)
If Not address.IsUnknown Then
Console.WriteLine("Country: {0}, Zip: {1}",
address.CountryRegion,
address.PostalCode)
Else
Console.WriteLine("Address unknown.")
End If
End If
Else
Console.WriteLine("GeoCoordinateWatcher timed out on start.")
End If
End Sub