O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Geolocator Class

The Geolocator class can be used by your app to monitor the location of the phone. It contains events for monitoring hardware state changes and geographic position changes.

Retrieving the Current Location

Geolocator allows you to track the phone’s location, using its PositionChanged event, and to retrieve the phone’s current location using its GetGeopositionAsync method.

The GetGeopositionAsync method forgoes the need to subscribe to the PositionChanged event when all you need is a single reading. With GetGeopositionAsync you can use the await keyword to conveniently wait for the method to return the Geoposition result, as shown in the following example:

var geolocator = new Geolocator();Geoposition ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required