Working With Location in Windows Phone: Listing 1

Creating the GeoCoordinateWatcher.

private GeoCoordinateWatcher watcher;
public void StartTracking()
{
    if (watcher == null)
    {
        watcher = new GeoCoordinateWatcher();
        watcher.StatusChanged += LocationStatusChanged;
        watcher.PositionChanged += LocationPositionChanged;
        watcher.Start();
    }
}

public void StopTracking()
{
    if (watcher != null)
    {
        watcher.Stop();
        watcher.StatusChanged -= LocationStatusChanged;
        watcher.PositionChanged -= LocationPositionChanged;
        watcher = null;
    }
}

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus

Featured

Subscribe on YouTube