Package | com.myflashlab.air.extensions.gps |
Class | public class Gps |
Inheritance | Gps flash.events.EventDispatcher |
Make sure to take care of the permissions manually if you are targeting AIR SDK 24+: https://github.com/myflashlab/GPS-ANE/#permissions
Property | Defined By | ||
---|---|---|---|
geocoding : GeocodingManager [static] | Gps | ||
geofencing : GeofencingManager [static] | Gps | ||
location : LocationManager [static] | Gps | ||
state : State [static] | Gps |
Method | Defined By | ||
---|---|---|---|
Gps() | Gps | ||
dispose():void [static]
when you're done with this extension, call this method to clean up the memory. | Gps | ||
[static]
Call this static method only once in your project to have access to all other GPS features
| Gps | ||
requestAlwaysAuthorization():void [static]
Deprecated, Please use the PermissionCheck ANE instead. | Gps |
Constant | Defined By | ||
---|---|---|---|
EXTENSION_ID : String = com.myflashlab.air.extensions.gps [static] | Gps | ||
VERSION : String = 4.0.3 [static] | Gps |
geocoding | property |
public static var geocoding:GeocodingManager
geofencing | property |
public static var geofencing:GeofencingManager
location | property |
public static var location:LocationManager
state | property |
public static var state:State
Gps | () | Constructor |
public function Gps()
dispose | () | method |
public static function dispose():void
when you're done with this extension, call this method to clean up the memory. you wouldn't need to call this method at all
but we added it for your convenient. to stop GPS service, all you need to do is to remove the listener and call
Gps.location.stop();
init | () | method |
public static function init():Gps
Call this static method only once in your project to have access to all other GPS features
ReturnsGps — |
requestAlwaysAuthorization | () | method |
public static function requestAlwaysAuthorization():void
Deprecated, Please use the PermissionCheck ANE instead. http://www.myflashlabs.com/product/native-access-permission-check-settings-menu-air-native-extension/
EXTENSION_ID | Constant |
public static const EXTENSION_ID:String = com.myflashlab.air.extensions.gps
VERSION | Constant |
public static const VERSION:String = 4.0.3
import com.myflashlab.air.extensions.gps.Gps; import com.myflashlab.air.extensions.gps.LocationAccuracy; import com.myflashlab.air.extensions.gps.Location; import com.myflashlab.air.extensions.gps.GpsEvent; Gps.init(); // call init only once in your project // will return null if no known last location has been found Gps.location.getLastLocation(onLocationResult); // 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("---------------------------------"); } // use the start method to get gps information periodically (the gps icon will be shown at your device status bar) Gps.location.addEventListener(GpsEvent.LOCATION_UPDATE, onLocationUpdate); Gps.location.start(LocationAccuracy.HIGH, 0, 5000); // simply stop the gps service when you don't need to get location information periodically anymore. Gps.location.removeEventListener(GpsEvent.LOCATION_UPDATE, onLocationUpdate); Gps.location.stop(); function onLocationUpdate(e:GpsEvent):void { trace(" ------------------------------- onLocationUpdate"); var loc:Location = e.param; trace("accuracy = " + loc.accuracy); trace("altitude = " + loc.altitude); trace("bearing = " + loc.bearing); trace("latitude = " + loc.latitude); trace("longitude = " + loc.longitude); trace("provider = " + loc.provider); trace("speed = " + loc.speed); trace("time = " + loc.time); trace("---------------------------------"); }
Gps.geocoding.reverse(-33.7969235, 150.9224326, onResultGeocodingReverse); function onResultGeocodingReverse($address:Array):void { // there might be more than one address found for this location trace("$address.length = " + $address.length); trace("$address = " + JSON.stringify($address)); trace("-----------------------------"); } Gps.geocoding.direct("Sydney", onResultGeocodingDirect); function onResultGeocodingDirect($location:Array):void { // there might be more than one location found for this address trace("$location.length = " + $location.length); trace("$location = " + JSON.stringify($location)); trace("-----------------------------"); }