Maps Android#
The Map Service enables PED to retrieve and display flight path visuals as images supplied by the IFE system. These images illustrate the current route along with relevant waypoints.
Step 1: Initialisation of Map service#
The BroadcastMapV1 class is responsible for managing map-related functionality, offering the APIs and properties required to access and interpret these broadcasted visuals.
InFlight mInFlight = new InFlight();
private BroadcastMapV1 mBroadcastMapV1
BroadcastMapV1.initService(this, new IInFlightCallback() {
@Override
public void onInitServiceComplete(Object o, String s) {
//Map Service intialized successfully
mBroadcastMapV1 = (BroadcastMapV1) o;
}
@Override
public void onInitServiceFailed(String s, InFlight.Error error) {
//Error during initialization of Map Service
}
}, mInFlight);
Parameters
-
context: The application context for service initialization.
-
callback: A callback interface (IInFlightCallback) that handles initialization results, the interface contains two methods.
-
inFlight: An instance of the InFlight system for service connectivity.
Step 2: Map Image resolutions#
Before displaying flight map images, the application must first select an appropriate resolution. The Map Service offers multiple resolution options, and choosing the right one ensures optimal image clarity, consistent UI presentation, and better performance based on the PED’s screen size or layout requirements.
This process includes retrieving the list of supported resolutions, selecting or customizing one to suit your UI design, and configuring the service with the selected resolution.
a. Get available resolutions
Retrieves all supported resolutions (in terms of width and height) for the flight map image. The returned values are only valid when the BroadcastMapV1.FlightMapImageAvailableResolutionChangedListener callback has been invoked. If this callback has not been triggered, the method will return a null object.
The method returns the list of FlightMapImageResolution, the object contains width and height of image. Example -
ArrayList<FlightMapImageResolution> resolutionList = mBroadcastMapV1.getFlightMapImageAvailableResolutions();
b. Set a Resolution for Map Image
After selecting a preferred resolution from the list of available options, this method can be used to apply the chosen resolution to update the flight map image accordingly.
The method returns true if the update is successfully applied; otherwise, it returns false to indicate failure.
Parameter:
- FlightMapImageResolution - A FlightMapImageResolution object must be provided, with both width and height values set as floating-point numbers.
ArrayList<FlightMapImageResolution> resolutionList = mBroadcastMapV1.getFlightMapImageAvailableResolutions();
FlightMapImageResolution resolution = resolutionList.get(0);
boolean status = mBroadcastMapV1.setFlightMapImageCurrentResolution(resolution);
In the example above, the resolution is selected from the list returned by getFlightMapImageAvailableResolutions. After comparing the available options, the resolution at index 0 is found to be suitable for the PED and is therefore set using setFlightMapImageCurrentResolution.
Developers can choose a custom resolution for the map image instead of using the predefined options from the getFlightMapImageAvailableResolutions method. This is helpful when the app has a fixed layout or needs a specific image size that doesn't match the default presets.
To set a custom resolution, there's no need to call getFlightMapImageAvailableResolutions, you can directly define the resolution using a FlightMapImageResolution object, and apply it using the existing resolution-setting APIs.
FlightMapImageResolution resolution = new FlightMapImageResolution();
resolution.setWidth(1920f);
resolution.setHeight(1020f);
boolean status = mBroadcastMapV1.setFlightMapImageCurrentResolution(resolution);
Recommended Practice: Always set a resolution after initializing the service to ensure consistent and reliable behavior, if no resolution has been explicitly set, the service will automatically select the first available resolution from the list. However, if there are no resolutions available at the time of request, the map image may fail to load.
c. Retrieve the Current Resolution
This method is used to retrieve the resolution that is currently active or applied by the map service.
This is helpful in situations where you want to reapply the same resolution—such as after a UI layout update or if the map service has been reinitialized—without having to fetch the list of available resolutions again. By retrieving the currently active resolution, you can ensure consistency without performing an additional query
Example -
d. Handle Resolution Changes Dynamically
In certain scenarios, the IFE (In-Flight Entertainment) system may update the list of available map image resolutions during the flight. To respond to these updates in real-time, the app should register a listener to receive notifications when such changes occur.
The system provides an event through the FlightMapImageAvailableResolutionChangedListener, which is triggered whenever the available resolutions are updated. To start listening for these changes, the app must register this listener using the setFlightMapImageAvailableResolutionChangedListener method. This allows the app to dynamically adjust to updated resolution options without requiring a manual refresh.
mBroadcastMapV1.setFlightMapImageAvailableResolutionChangedListener(new FlightMapImageAvailableResolutionChangedListener() {
@Override
public void onFlightMapImageAvailableResolutionChanged(ArrayList<FlightMapImageResolution> resolutionList) {
//The method provides the list available resolutions
}
@Override
public void onFlightMapError(Error error) {
//This method is called when an error occurs in the map service
}
});
Step 3: Start and Stop Retrieving Map Images#
After setting the desired resolution for the map image, the next step is to begin receiving live map images from the In-Flight Entertainment (IFE) system. This process is handled through the BroadcastMapV1 service object, which manages communication with the map service and provides the necessary interfaces for image retrieval.
The setFlightMapImageUpdatesRcvEnabled method is used to start or stop receiving map images from the IFE system. It acts as a toggle to control the flow of image data to the app based on the current app state (e.g., foreground or background). To begin receiving live flight map images, this method must be called with enable = true. Once enabled, the app will start receiving map image updates via the FlightMapImageReadyListener callback. If the updates are later disabled - either explicitly by the app or due to certain service conditions - the FlightMapImageStoppedReceivingImageListener will be triggered to indicate that image updates have stopped.
When the activity moves to the background or the map screen is no longer visible (e.g., user navigates away or switches tabs), developers should call the setFlightMapImageUpdatesRcvEnabled method with false to prevent unnecessary processing and conserve system resources. This ensures that the app does not continue receiving map image updates when they are not needed. Note that calling stop does not trigger any notification or callback-it simply halts the data flow for that session.
Example -
In the example above, passing true to the method enables map image updates from the IFE system, which are delivered via the FlightMapImageReadyListener callback. Conversely, passing false stops the updates, and the FlightMapImageStoppedReceivingImageListener is invoked to indicate that image delivery has been halted.
private BroadcastMapV1.FlightMapImageReadyListener mFlightMapImageReadyListener = new BroadcastMapV1.FlightMapImageReadyListener() {
@Override
public void onFlightMapImageReady(final Bitmap bitmap) {
//The map bitmap has been obtained and should now be applied to the ImageView displaying the map.
if (bitmap != null) {
imageViewMap.setImageBitmap(bitmap);
}
}
@Override
public void onFlightMapError(Error error) {
//Error occured during retriving the bitmap
}
};
Version 1.0