CivicAddressResolver.ResolveAddress(GeoCoordinate) Methode

Definitie

Hiermee wordt een burgeradres synchroon omgezet vanaf een locatie op basis van breedtegraad en lengtegraad. Met deze aanroep wordt de uitvoering van de aanroepende thread geblokkeerd terwijl het adres wordt opgelost.

public:
 virtual System::Device::Location::CivicAddress ^ ResolveAddress(System::Device::Location::GeoCoordinate ^ coordinate);
public System.Device.Location.CivicAddress ResolveAddress(System.Device.Location.GeoCoordinate coordinate);
abstract member ResolveAddress : System.Device.Location.GeoCoordinate -> System.Device.Location.CivicAddress
override this.ResolveAddress : System.Device.Location.GeoCoordinate -> System.Device.Location.CivicAddress
Public Function ResolveAddress (coordinate As GeoCoordinate) As CivicAddress

Parameters

coordinate
GeoCoordinate

De GeoCoordinate locatie die moet worden omgezet in een adres.

Retouren

Het burgeradres dat is omgezet vanuit de coordinate parameter. Unknown wordt geretourneerd als het adres niet kan worden omgezet.

Implementeringen

Uitzonderingen

coordinate is null.

coordinate bevat geen geldige breedte- en lengtegraad.

Voorbeelden

Het volgende programma laat zien hoe ResolveAddress u een civic address synchroon kunt oplossen.

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

Opmerkingen

De ResolveAddressCompleted gebeurtenis wordt gegenereerd wanneer de oplossingsbewerking van het adres is voltooid. Het burgeradres dat wordt omgezet vanuit de coordinate parameter, wordt geretourneerd door het Address lid van het ResolveAddressCompletedEventArgs object dat wordt doorgegeven aan de gebeurtenis-handler.

Van toepassing op