Packagecom.myflashlab.air.extensions.gps
Classpublic class LocationManager
InheritanceLocationManager Inheritance flash.events.EventDispatcher

This class is responsible for getting Gps information. find sample usage codes in Gps class.



Public Methods
 MethodDefined By
  
LocationManager($context:ExtensionContext)
do not try to initialize this class manually.
LocationManager
  
getCurrentLocation($onResult:Function):void
Use this method to receive the current user location.
LocationManager
  
getLastLocation($onResult:Function):void
Use this method to receive the last known Gps information which is not necessarilly the user's actual location.
LocationManager
  
start($accuracy:int, $distance:Number, $interval:Number):void
Use this method only if you need Gps information periodically in your app.
LocationManager
  
stop():void
Call this method to stop the Gps service.
LocationManager
Constructor Detail
LocationManager()Constructor
public function LocationManager($context:ExtensionContext)

do not try to initialize this class manually. instead, init the main Gps class and access this class using Gps.location

Parameters
$context:ExtensionContext
Method Detail
getCurrentLocation()method
public function getCurrentLocation($onResult:Function):void

Use this method to receive the current user location. If user Gps settings are off, a dialog will automatically promote the user to turn Gps service on.

Parameters

$onResult:Function — A function that you specify to receive location information. the function you specify must receive one parameter of type Location

See also


Example
The following example shows how to use getCurrentLocation
        import com.myflashlab.air.extensions.gps.Gps;
        import com.myflashlab.air.extensions.gps.Location;
             Gps.init(); // call init only once in your project
             // may take a while depending on when gps info is found
        Gps.location.getCurrentLocation(onLocationResult);
             function onLocationResult($result:Location):void
        {
         if (!$result)
         {
             trace("location is null");
             return;
         }
              trace("accuracy = " + $result.accuracy);
         trace("altitude = " + $result.altitude);
         trace("bearing = " + $result.bearing);
         trace("latitude = " + $result.latitude);
         trace("longitude = " + $result.longitude);
         trace("provider = " + $result.provider);
         trace("speed = " + $result.speed);
         trace("time = " + $result.time);
         trace("---------------------------------");
     }
     
getLastLocation()method 
public function getLastLocation($onResult:Function):void

Use this method to receive the last known Gps information which is not necessarilly the user's actual location. to make sure you are receiving the user's actual location, use getCurrentLocation method. if your app is running for the first time, this method will return null location

Parameters

$onResult:Function — A function that you specify to receive location information. the function you specify must receive one parameter of type Location

See also


Example
The following example shows how to use getLastLocation
        import com.myflashlab.air.extensions.gps.Gps;
        import com.myflashlab.air.extensions.gps.Location;
             Gps.init(); // call init only once in your project
             // will return null if no known last location has been found
        Gps.location.getLastLocation(onLocationResult);
             function onLocationResult($result:Location):void
        {
         if (!$result)
         {
             trace("location is null");
             return;
         }
              trace("accuracy = " + $result.accuracy);
         trace("altitude = " + $result.altitude);
         trace("bearing = " + $result.bearing);
         trace("latitude = " + $result.latitude);
         trace("longitude = " + $result.longitude);
         trace("provider = " + $result.provider);
         trace("speed = " + $result.speed);
         trace("time = " + $result.time);
         trace("---------------------------------");
     }
     
start()method 
public function start($accuracy:int, $distance:Number, $interval:Number):void

Use this method only if you need Gps information periodically in your app. you can specify the distance and interval and the extension will keep dispatching the location to your app. When you use this method, the Gps icon will be shown on your device status bar. Also it's good to know that this method will use battery a lot. so, make sure to turn it off when you no longer need it.

Parameters

$accuracy:int — The accuracy level you need for receiving gps information
 
$distance:Number — The minimum user movement you need to be updated with gps information
 
$interval:Number — The minimum time intervals you want to receive Gps information

See also

stop()method 
public function stop():void

Call this method to stop the Gps service. as soon as you call this method, the Gps icon will be removed from the device's status bar and your Gps listener won't receive any events anymore.