CivicAddress 클래스

정의

도심 주소를 나타냅니다. 도심 주소에는 주소, 우편 번호, 시/도 및 국가 또는 지역 같은 필드가 포함될 수 있습니다.

public ref class CivicAddress
public class CivicAddress
type CivicAddress = class
Public Class CivicAddress
상속
CivicAddress

예제

다음 예제에서는 해결 방법을 보여 줍니다.는 CivicAddress 에서 GeoCoordinate 위치 동기적으로 합니다.

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 == 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.");
                }
            }
        }
    }
}
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

다음 예제에서는 해결 방법을 보여 줍니다.는 CivicAddress 에서 GeoCoordinate 위치 비동기적으로 합니다.

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 == false)
                {
                    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 반환 된 CivicAddress 현재 위치에 대 한 합니다. 원본 위치로 좌표 위치를 도심 주소를 확인할 수 없는 경우 Unknown 반환 됩니다.

생성자

CivicAddress()

CivicAddress 클래스의 새 인스턴스를 초기화합니다.

CivicAddress(String, String, String, String, String, String, String, String)

주소 정보를 사용하여 CivicAddress 클래스의 새 인스턴스를 초기화합니다.

필드

Unknown

데이터를 포함하지 않는 CivicAddress를 나타냅니다.

속성

AddressLine1

주소의 첫째 줄을 가져오거나 설정합니다.

AddressLine2

주소의 둘째 줄을 가져오거나 설정합니다.

Building

건물 이름 또는 번호를 가져오거나 설정합니다.

City

구/군/시의 이름을 가져오거나 설정합니다.

CountryRegion

위치의 국가/지역을 가져오거나 설정합니다.

FloorLevel

위치의 층 수를 가져오거나 설정합니다.

IsUnknown

CivicAddress에 데이터가 있는지 여부를 나타내는 값을 가져옵니다.

PostalCode

위치의 우편 번호를 가져오거나 설정합니다.

StateProvince

위치의 시/도를 가져오거나 설정합니다.

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상