Geolocation Sample for Windows Phone 7

This sample shows how to use the location service on Windows Phone 7.

Sample Overview

This sample demonstrates a simple car finder—a way to find a car in a large parking lot. When the car is parked and the location service is ready, the current location of the phone is saved by pressing the Save location button. This helps you to later find the saved location.

How to Use the Sample

When you walk around with the phone, it shows you how your current location is related to your saved location. It shows your current moving speed, direction, and position (in terms of latitude, longitude, and altitude). The sample also shows how far away you are from the saved location.

At the bottom of the screen display, the green arrow shows your moving direction, and the red spot shows the saved location. As long as your moving direction is toward the red spot, you are getting closer to the saved location.

The graphical display supports two modes—north up and your direction up. You can switch between these two modes at your discretion.

How the Sample Works

The sample uses the location service of Windows Phone 7 to track the phone's current location. When the sample is deactivated, it serializes the saved location to the isolated storage. Upon reactivation, the saved location reloads. Regardless if you exit the sample or let it run continuously, it is always aware of the last saved location.

Note that since DateTimeOffset (which is part of geolocation structure) cannot be serialized by using XmlSerializer, the sample implemented its own method to store/load the geolocation data to and from the isolated storage instead of using the standard XmlSerializer.