Managing errors and load-on-demand events

The load-on-demand mechanism might generate errors when the map cannot be entirely loaded due to memory problems, absence of data, loss of connection to a server and so on. Graphic applications must catch these errors to inform the user that the map being viewed is not complete.
To be notified of these events, and any other events related to load-on-demand, you can set a TileListener to an instance of the IlvTileController class. This listener is notified of all changes to the tiles, for example, the beginning or end of loading, moving tiles into the cache, or out of the cache for reuse, loading errors, and so on.
The following example displays all the events related to load-on-demand:
lodLayer.getTileController().addTileListener(new TileListener() {
  public void tileChanged(TileEvent e) {
    System.err.print(e);
  }
});
By default, the tile controller displays a message on the screen if an error occurs while a tile is being loaded. You can deactivate this behavior using the following method:
The different types of events sent to the tile listeners are:
  • TILE_ABOUT_TO_LOAD Triggered when a tile is about to be loaded into memory.
  • TILE_LOADED Triggered when a tile has been loaded into memory.
  • TILE_CACHED Triggered when a tile that is no longer being used is stored in the cache.
  • TILE_RETRIEVED Triggered when the counter of a tile stored in the cache is incremented again. The tile can no longer be unloaded.
  • TILE_RELEASED Triggered when a tile is completely freed.
  • ERROR Triggered when an error occurs while a tile is being processed. In this case, the getThrowable method of TileEvent allows you to know the exception or the error that caused the problem.
  • CONTROLLER_DISPOSED Triggered when the tile controller is deactivated. For example, if you remove its associated tiled layer from a manager.
  • NO_CHANGE Triggered when the last event in a series of events is processed.
When an event in a view causes an action to be performed on a tile, the tile controller notifies the tile listener of the action. If this event provokes a series of transitional events, these are transmitted to the listener as a group. Therefore, modifying a scale factor can cause new tiles to be loaded and other tiles to be cached. Grouping events allows an action to be performed only when all the transitional events it causes are completed. The isAdjusting() method of the class TileEvent returns true if the event is part of a series of events. The NO_CHANGE event is sent once the last event in a series is processed and the isAdjustmentEnd() method returns true .