Accessing device location information

The Location Service API allows Flash Lite applications to retrieve information about the physical location of a device and to perform calculations based on location information. You can use the Location Service to create Flash Lite applications that provide location-based services (LBS). For example, you can create Flash Lite applications that:

  • Provide directions to a destination, for example the nearest restaurant

  • Monitor the locations of snow-plowing vehicles

  • Calculate distances between geographical locations

For example code snippets that focus on common Location Service use cases, see section Flash Lite components and code snippets.

The Location Service relies on the GPS capabilities of the device to provide location information. If the device does not include or is not connected to a positioning system, the service cannot provide such information.

Accessing the API and supported methods

To create a service object for the Location Service API, use Service.Location to identify the service provider and ILocation to identify the supported interface:

var location = new Service("Service.Location", "ILocation");

The ILocation interface provides the following methods:

  • GetLocation()

    Use the GetLocation() method to retrieve the current location of the device.

  • Trace()

    Use the Trace() method to retrieve periodic updates about the current location of the device.

  • Calculate()

    Use the Calculate() method to perform mathematical calculations based on a source location and a target location.

  • CancelNotification()

    Use the CancelNotification() method to cancel an ongoing asynchronous call. This method is valid for any asynchronous call made through the Location Service API.