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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.