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

Get Windows® Phone 8 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.