CivicAddress 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
시민 주소를 나타냅니다. 시민 주소에는 주소, 우편 번호, 시/도, 국가 또는 지역과 같은 필드가 포함될 수 있습니다.
public ref class CivicAddress
public class CivicAddress
type CivicAddress = class
Public Class CivicAddress
- 상속
-
CivicAddress
예제
다음 예제에서는 위치에서 동기적으로 확인하는 CivicAddressGeoCoordinate 방법을 보여 있습니다.
using System;
using System.Device.Location;
namespace ResolveAddressSync
{
class Program
{
static void Main(string[] args)
{
ResolveAddressSync();
}
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)
{
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.");
}
}
}
}
}
Imports System.Device.Location
Module ResolveAddressSync
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
Public Sub Main()
ResolveAddressSync()
Console.WriteLine("Enter any key to quit.")
Console.ReadLine()
End Sub
End Module
다음 예제에서는 비동기적으로 위치에서 확인 CivicAddressGeoCoordinate 하는 방법을 보여 있습니다.
using System;
using System.Device.Location;
namespace ResolveAddressSync
{
class AsyncProgram
{
public static void Main(string[] args)
{
ResolveAddressAsync();
}
static void ResolveAddressAsync()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
bool started = false;
watcher.MovementThreshold = 1.0; // set to one meter
started = watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
if (started)
{
CivicAddressResolver resolver = new CivicAddressResolver();
resolver.ResolveAddressCompleted += new EventHandler<ResolveAddressCompletedEventArgs>(resolver_ResolveAddressCompleted);
if (!watcher.Position.Location.IsUnknown)
{
resolver.ResolveAddressAsync(watcher.Position.Location);
}
}
}
static void resolver_ResolveAddressCompleted(object sender, ResolveAddressCompletedEventArgs e)
{
if (!e.Address.IsUnknown)
{
Console.WriteLine("Country: {0}, Zip: {1}",
e.Address.CountryRegion,
e.Address.PostalCode);
}
else
{
Console.WriteLine("Unknown address.");
}
}
}
}
Imports System.Device.Location
Module ResolveCivicAddressAsync
Public Sub ResolveCivicAddressAsync()
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))
If started Then
Dim resolver As CivicAddressResolver = New CivicAddressResolver()
AddHandler resolver.ResolveAddressCompleted, AddressOf resolver_ResolveAddressCompleted
If Not watcher.Position.Location.IsUnknown Then
resolver.ResolveAddressAsync(watcher.Position.Location)
End If
End If
watcher.Start()
End Sub
Sub resolver_ResolveAddressCompleted(ByVal sender As Object, ByVal e As ResolveAddressCompletedEventArgs)
If Not e.Address.IsUnknown Then
Console.WriteLine("Country: {0}, Zip: {1}",
e.Address.CountryRegion,
e.Address.PostalCode)
Else
Console.WriteLine("Unknown address.")
End If
End Sub
Public Sub Main()
ResolveCivicAddressAsync()
Console.WriteLine("Enter any key to quit.")
Console.ReadLine()
End Sub
End Module
설명
위치에 대한 시민 주소는 구현하는 클래스를 GeoCoordinate 사용하여 가져올 수 있습니다 ICivicAddressResolver.
이 클래스는 CivicAddressResolver 위치 원본이 좌표 데이터와 시민 주소 GeoCoordinate데이터를 모두 제공하는 경우 해당 시민 주소를 반환하는 기본 구현을 제공합니다.
ResolveAddress 는 현재 위치에 대한 a CivicAddress 를 반환합니다. 위치 원본이 좌표 위치를 시민 주소 Unknown 로 확인할 수 없는 경우 반환됩니다.
생성자
| Name | Description |
|---|---|
| CivicAddress() |
CivicAddress 클래스의 새 인스턴스를 초기화합니다. |
| CivicAddress(String, String, String, String, String, String, String, String) |
주소 정보를 사용하여 클래스의 새 인스턴스를 CivicAddress 초기화합니다. |
필드
| Name | Description |
|---|---|
| Unknown |
CivicAddress 데이터가 없는 항목을 나타냅니다. |
속성
| Name | Description |
|---|---|
| AddressLine1 |
주소의 첫 번째 줄을 가져오거나 설정합니다. |
| AddressLine2 |
주소의 두 번째 줄을 가져오거나 설정합니다. |
| Building |
건물 이름 또는 번호를 가져오거나 설정합니다. |
| City |
도시의 이름을 가져오거나 설정합니다. |
| CountryRegion |
위치의 국가 또는 지역을 가져오거나 설정합니다. |
| FloorLevel |
위치의 바닥 수준을 가져오거나 설정합니다. |
| IsUnknown |
데이터가 포함되어 있는지 여부를 CivicAddress 나타내는 값을 가져옵니다. |
| PostalCode |
위치의 우편 코드를 가져오거나 설정합니다. |
| StateProvince |
위치의 상태 또는 지방을 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |