Udostępnij za pośrednictwem


.NET Location API for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Note

Windows Phone 8 has a new Windows Phone Runtime API for creating location-aware apps. The content in this topic applies to the .NET Location API which was introduced in Windows Phone OS 7.0 and which is still fully supported. For information on which API set is right for your application, see Location for Windows Phone 8.

The Microsoft Location Service allows you to create location-aware applications for Windows Phone. The service obtains location data from multiple sources such as GPS, Wi-Fi, and cellular. It can use one or more of these sources to deduce the location of the Windows Phone, balancing performance with power utilization depending on an application’s needs. The location is exposed to applications through an event-driven managed code interface.

Location Service Architecture

The first layer consists of hardware in the Windows Phone device. This includes the GPS receiver, Wi-Fi, and the cellular radio. These can all function as providers of location data with varying levels of accuracy and power consumption. On top of the hardware sits the native code layer. This layer communicates directly with the available sources of location data and decides which sources to use to determine the location of the device based on the availability of data and on the performance requirements specified by the application. The native code layer also communicates over the Internet with a Microsoft-hosted web service to look up location-related information from a database. The top layer of the Location Service is the managed interface, exposed through a DLL that is included with Windows Phone SDK. An application uses this interface to start and stop the location service, to set the level of accuracy required by the application, and to receive location data from the native code layer as it becomes available.