Maps > Using Load-On-Demand > Managing Errors and Load-on-Demand Events
 
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. 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 an IlvTileListener to an instance of the IlvTileController class. This listener is notified of changes to the tiles and its tileChanged method is called each time the status of a tile has changed. The events related to the cache mechanism are available by subtyping the IlvTileCache class:
*void IlvTileCache::tileAboutToLoad(IlvTile* tile)
Called when the specified tile is about to be loaded.
*void IlvTileCache::tileCached(IlvTile* tile)
Called when the specified tile is to be inserted in the cache.
*void IlvTileCache::tileRetrieved(IlvTile* tile)
Called when the specified tile is to be removed from the cache.
The following example displays all the events related to load-on-demand:
 
static const char*
toString(IlvTileStatus status) {
switch(status) {
case IlvTileEmpty:
return "IlvTileEmpty";
case IlvTileLocked:
return "IlvTileLocked";
case IlvTileCached:
return "IlvTileCached";
case IlvTileDeleted:
return "IlvTileDeleted";
}
}
 
void
Listener::tileChanged(IlvTile* tile,
IlvTileStatus oldStatus,
IlvTileStatus newStatus)
{
IlvPrint("tile %d %d status changed from %s to %s",
tile->getRow(), tile->getColumn(),
toString(oldStatus),
toString(newStatus));
}
 
void
SimpleLod::listener()
{
_listener = new Listener(_manager, _view);
_tiledLayer->getTileController()->addTileListener(_listener);
}
 
The different types of events sent to the tile listeners are the following:
*IlvTileEmptyInitial status of the tile (the tile contains no objects).
*IlvTileLockedTriggered when a tile has been loaded into memory.
*IlvTileCachedTriggered when a tile that is no longer being used is stored in the cache.
*IlvTileDeletedTriggered when a tile is completely freed.
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 triggers 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 start of the event group is notified by the call of the following method beginGroupedNotification and the end of the event group notified by the call of the following method endGroupedNotification.

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.