CivicAddress Class

.NET Framework (current version)
 

Represents a civic address. A civic address can include fields such as street address, postal code, state/province, and country or region.

Namespace:   System.Device.Location
Assembly:  System.Device (in System.Device.dll)

System.Object
  System.Device.Location.CivicAddress

Public Class CivicAddress

NameDescription
System_CAPS_pubmethodCivicAddress()

Initializes a new instance of the CivicAddress class.

System_CAPS_pubmethodCivicAddress(String, String, String, String, String, String, String, String)

Initializes a new instance of the CivicAddress class using address information.

NameDescription
System_CAPS_pubpropertyAddressLine1

Gets or sets the first line of the address.

System_CAPS_pubpropertyAddressLine2

Gets or sets the second line of the address.

System_CAPS_pubpropertyBuilding

Gets or sets the building name or number.

System_CAPS_pubpropertyCity

Gets or sets the name of the city.

System_CAPS_pubpropertyCountryRegion

Gets or sets the country or region of the location.

System_CAPS_pubpropertyFloorLevel

Gets or sets the floor level of the location.

System_CAPS_pubpropertyIsUnknown

Gets a value that indicates whether the CivicAddress contains data.

System_CAPS_pubpropertyPostalCode

Gets or sets the postal code of the location.

System_CAPS_pubpropertyStateProvince

Gets or sets the state or province of the location.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticUnknown

Represents a CivicAddress that contains no data.

A civic address for a location can be obtained from a GeoCoordinate by using a class that implements ICivicAddressResolver.

The 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.

ResolveAddress returns a CivicAddress for the current location. If the location source is unable to resolve the coordinate position to a civic address, Unknown is returned.

The following example shows how to resolve a CivicAddress from a GeoCoordinate location synchronously.

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

The following example shows how to resolve a CivicAddress from a GeoCoordinate location asynchronously.

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

.NET Framework
Available since 4.0
Windows Phone Silverlight
Available since 7.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: