Controlling load-on-demand

Using visibility filters to control load-on-demand

If you do not want to use the dynamic styles provided by the IlvMapStyleController class, you can use scale visibility filters to control the display of tiles in a manager layer.
When a scale visibility filter has been set for a tiled layer, this layer will be displayed if the scale factor set for its manager view is within specified scale limits. Otherwise, it will be hidden. When a tiled layer is visible because the zoom factor of the manager view allows it, visible tiles are automatically locked and thus loaded into memory. In the same way, when a tiled layer is hidden because the zoom level of its view exceeds a certain value, all the locks set on visible tiles are released and the tiles are removed.
Scale visibility filters are generally used to activate load-on-demand for zoom factors between a minimum and a maximum scale value. Let us consider a map scanned with a scale of 1/1,000,000, you can set visibility filters so that its layer is visible for scale factors ranging from 1/2,500,000 to 1/500,00.

Setting tile locking filters

You can use the IlvTileLockFilter class to dynamically prevent a tile from being loaded when it becomes visible in a view. To do so, you associate an IlvTileLockFilter object with a tile controller using the following method:
If the tile controller possesses a lock filter, it calls the method isLockAllowed of the lock filter each time a tile becomes visible in a view. If this method returns false , the counter of the tile is not incremented.
Using a lock filter, you can prevent the loading of data displayed at a small scale (when a map is zoomed out greatly, for example) while leaving the tiles that were already loaded visible.

Loading tiles using the API

The load-on-demand mechanism is event-driven in that cartographic data is loaded or unloaded following user’s actions, such as zooming or panning. You can, however, use the lockTile() method for example—to preload a tile corresponding to a map zone that is visited frequently or to prevent the tile from being unloaded.
The lockTile() method shown below increments the tile lock counter:
If the tile lock counter is equal to zero, the tile is loaded into memory and will not be unloaded as long as the lock is not released—with the IlvTileController.unlockTile method, for example.

Updating all the visible tiles in a view

Sometimes you may need to update immediately all the tiles that are currently viewed by an IlvManagerView. You can then use the updateView method. It can be useful when you reactivate a view that was ignored until then by the load-on-demand mechanism.