Location Tracking

In Chapter 17 you saw how a Geolocator provides geographic location updates. In this section you see how the custom IGeoLocator (presented in that chapter) can be used to track the location of the phone using a Map control.

The MapViewModel class’s StartTracking method instantiates either a GeolocatorProxy or a MockGeoLocator, depending on whether the class is executing within the emulator (see Listing 18.2).

When the GeoLocatorSampler object’s PropertyChanged event is raised, the Location, Center, and PositionStatus properties are updated. Changing the Center property changes the visible center point of the Map control and pans the map to the new GeoCoordinate.

An AppBarToggleButton in the view is data-bound to the viewmodel’s ...

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.