다음을 통해 공유


ICivicAddressResolver.ResolveAddressAsync(GeoCoordinate) 메서드

정의

위도/경도 위치를 주소로 확인하는 요청을 시작합니다.

public:
 void ResolveAddressAsync(System::Device::Location::GeoCoordinate ^ coordinate);
public void ResolveAddressAsync (System.Device.Location.GeoCoordinate coordinate);
abstract member ResolveAddressAsync : System.Device.Location.GeoCoordinate -> unit
Public Sub ResolveAddressAsync (coordinate As GeoCoordinate)

매개 변수

coordinate
GeoCoordinate

주소를 확인할 위도/경도 위치입니다.

예제

다음 예제에서는 호출 하는 방법을 보여 줍니다 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.");
    }
}

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

설명

이 메서드는 메서드의 동기 대응에서 throw할 수 있는 모든 비사용 예외를 반환하는 작업에 저장됩니다. 예외가 반환된 작업에 저장되면 작업이 대기될 때 해당 예외가 throw됩니다. 와 같은 ArgumentException사용 예외는 여전히 동기적으로 throw됩니다. 저장된 예외는 에서 throw ResolveAddress(GeoCoordinate)된 예외를 참조하세요.

적용 대상

추가 정보