O'Reilly logo

Windows® Phone 7 Application Development 24-Hour Trainer by Brian Faucher

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 21. Using GPS

Windows Phone 7 Assisted GPS enables you to create applications that provide the user with relevant location-aware data, enhancing the user experience. As an example, if you are developing an application for a large coffee shop chain that has stores at 100 locations throughout a large metropolitan area, you can use the current location of the phone to display the five nearest locations. To provide this experience you might use a combination of the Location Service and the Bing Maps Service.

GETTING DATA FROM THE LOCATION SERVICE API

The Location Service API enables you to access a single API to retrieve information about the current location of the Windows Phone 7 device. Without this API you would have to write code to check for and use location data from three possible sources; the current GSM cell ID, the access point for WiFi (if WiFi is in use), and GPS data. With the Location Service API you need only make one call to the API to retrieve the current location.

Obtaining the Geographic Coordinates for a Location

The Location Service API takes care of the task of checking to see which of the aforementioned sources is able to provide data; it determines the best source to use and returns the data. To use the Location Service API you must first add a reference to the System.Device component to your application. Then you will need to add a using directive to the top of the class file for the page that will be using the Location Service:

using System.Device.Location; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required