Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ResolveAddressAsync Method
Collapse the table of content
Expand the table of content

CivicAddressResolver.ResolveAddressAsync Method

.NET Framework 4.6 and 4.5

Resolves an address asynchronously from a location that is based on latitude and longitude. The call does not block execution of the calling thread while the address is being resolved.

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

public void ResolveAddressAsync(
	GeoCoordinate coordinate
)

Parameters

coordinate
Type: System.Device.Location.GeoCoordinate

The GeoCoordinate containing the location to resolve to a civic address.

Implements

ICivicAddressResolver.ResolveAddressAsync(GeoCoordinate)

ExceptionCondition
ArgumentNullException

coordinate is null.

ArgumentException

coordinate does not contain a valid latitude and longitude.

The following program shows how to call ResolveAddressAsync to resolve a civic address 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.");
            }
        }


    }
}

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8
Show:
© 2015 Microsoft