GPS is a native extension to use the geographical location information of a device. It is able to read time, geographical location and the device’s last location information. When the location of the device changes, the application can receive updates about the changes too. All of the needed geographical location data (time, accuracy, latitude, longitude, altitude, speed, provider and bearing ) can be extracted in the form of an Object.
Even though Adobe AIR already has a Geolocation API, the extension has even more features, such as access to location menu, checking the GPS status ( Is it on or off), enabling/disabling listeners, checking GPS availability and the device GPS support.
var _ex:Gps; // initialize the extension _ex = new Gps(); // This listener tells you that the location menu has been closed. _ex.addEventListener(GpsEvent.LOCATION_MENU_CLOSED, closed); // This listener informs you when new location data is gained. _ex.addEventListener(GpsEvent.UPDATE_STATUS, location); // This listener informs you when the GPS is temporarily unavailable. _ex.addEventListener(GpsEvent.GPS_TEMPORARILY_UNAVAILABLE, unavailable); // This listener infors you when the device GPS has been activated. _ex.addEventListener(GpsEvent.GPS_ENABLE, enable); // This listener informs you when the device GPS has been deactivated. _ex.addEventListener(GpsEvent.GPS_DISABLE, disable); // If you want to find out whether the device supports GPS or not you can use the isSupported property. var Support:boolean = _ex.isSupported; trace("is Supported >> " + support); // If you want to find out whether the GPS is active or not you can use the isGpsEnabled property. var Enable:boolean = _ex.isGpsEnabled; trace("isGpsEnabled >>" + Enable); // In order to have access to the GPS location menu you can use the openLocationMenu() function. _ex.openLocationMenu();