CivicAddress CivicAddress CivicAddress CivicAddress Class

Определение

Представляет административный адрес.Represents a civic address. Административный адрес может включать следующие поля: уличный адрес, почтовый индекс, штат/область и страну или регион.A civic address can include fields such as street address, postal code, state/province, and country or region.

public ref class CivicAddress
public class CivicAddress
type CivicAddress = class
Public Class CivicAddress
Наследование
CivicAddressCivicAddressCivicAddressCivicAddress

Примеры

В следующем примере показано, CivicAddress как разрешить GeoCoordinate из расположения в синхронном режиме.The following example shows how to resolve a CivicAddress from a GeoCoordinate location synchronously.

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 из расположения в асинхронном режиме.The following example shows how to resolve a CivicAddress from a GeoCoordinate location asynchronously.

using System;
using System.Device.Location;
namespace ResolveAddressSync
{
    class Program
    {
        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 , используя класс, реализующий интерфейс. ICivicAddressResolverA civic address for a location can be obtained from a GeoCoordinate by using a class that implements ICivicAddressResolver.

Класс предоставляет реализацию по умолчанию, которая возвращает административный адрес, соответствующий объекту GeoCoordinate, если источник расположения предоставляет как данные координат, так и данные по административному адресу. CivicAddressResolverThe CivicAddressResolver class provides a default implementation that returns the civic address that corresponds to a GeoCoordinate, if the location source provides both coordinate data as well as civic address data.

ResolveAddressCivicAddress возвращает для текущего расположения.ResolveAddress returns a CivicAddress for the current location. Если источнику расположения не удается разрешить позицию координат в административный адрес, Unknown возвращается.If the location source is unable to resolve the coordinate position to a civic address, Unknown is returned.

Конструкторы

CivicAddress() CivicAddress() CivicAddress() CivicAddress()

Инициализирует новый экземпляр класса CivicAddress.Initializes a new instance of the CivicAddress class.

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

Инициализирует новый экземпляр класса CivicAddress, используя сведения об адресе.Initializes a new instance of the CivicAddress class using address information.

Поля

Unknown Unknown Unknown Unknown

Представляет CivicAddress, который не содержит данных.Represents a CivicAddress that contains no data.

Свойства

AddressLine1 AddressLine1 AddressLine1 AddressLine1

Получает или задает первую строку адреса.Gets or sets the first line of the address.

AddressLine2 AddressLine2 AddressLine2 AddressLine2

Получает или задает вторую строку адреса.Gets or sets the second line of the address.

Building Building Building Building

Получает или задает название или номер дома.Gets or sets the building name or number.

City City City City

Получает или задает название города.Gets or sets the name of the city.

CountryRegion CountryRegion CountryRegion CountryRegion

Получает или задает страну или регион расположения.Gets or sets the country or region of the location.

FloorLevel FloorLevel FloorLevel FloorLevel

Получает или задает этаж расположения.Gets or sets the floor level of the location.

IsUnknown IsUnknown IsUnknown IsUnknown

Возвращает значение, которое указывает, содержит ли CivicAddress данные.Gets a value that indicates whether the CivicAddress contains data.

PostalCode PostalCode PostalCode PostalCode

Получает или задает почтовый индекс расположения.Gets or sets the postal code of the location.

StateProvince StateProvince StateProvince StateProvince

Получает или задает штат или область расположения.Gets or sets the state or province of the location.

Методы

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Определяет, равен ли заданный объект текущему объекту.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Служит хэш-функцией по умолчанию.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Возвращает объект Type для текущего экземпляра.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Создает неполную копию текущего объекта Object.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Возвращает строку, представляющую текущий объект.Returns a string that represents the current object.

(Inherited from Object)

Применяется к