Load-on-demand for hierarchical data sources

To write a new IlvMapDataSource for a format of your own using the load-on-demand mechanism, you should inherit from the IlvTilableDataSource class. This class performs all of the steps required to create the appropriate tiles, and to configure tiled layers to make efficient use of load-on-demand. You can choose the number of rows and columns into which to divide the map, or even deactivate the tiling mechanism if you prefer. However, you need to implement two abstract methods:
protected abstract void createTiledLayers();
protected IlvMapRegionOfInterestIterator createTiledIterator(IlvMapLayer 
layer);
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps810/samples/mapbuilder/index.html

Creating tiled layers

The createTiledLayers method is called by the startmethod of the IlvMapDataSource. Its role is to create the tiled layers that make up this data source. For example, if your data source sorts map features into different layers, all of the tiled layers must be created by this method.
Here is a sample implementation of this method:
protected void createTiledLayers() {
  // get the insertion layer of this datasource (i.e. the ‘root’ layer
  // of this data source, potentially containing children layers)
  IlvMapLayer mapLayer = getInsertionLayer();
  
  // Create a tiled layer to associated with this IlvMapLayer (refer to the 
chapter
  // on tiled layers) 
  IlvTiledLayer currentTiledLayer = new IlvTiledLayer(new IlvRect(),new
  IlvDefaultTileCache(),IlvTileController.FREE);

  // associate this layer with the IlvMapLayer
  mapLayer.insert(currentTiledLayer);
}

Reading map features

The createTiledIterator method returns a feature iterator over map features located in a specified region of interest. The tile loaders of the layers use this iterator to load the tiles when they become available on screen. That is, they read the map features of the tiles in the region of interest only.
Here is a basic implementation of this method:
protected IlvMapRegionOfInterestIterator createTiledIterator(IlvMapLayer layer) 
throws IOException {
  // IlvMapLayer mapLayer = getInsertionLayer();
  if (layer != mapLayer) {
    // the layer in parameter has nothing to do with this data source
    return null;
  }
  // Create your region of interest feature iterator here,
  // basically an iterator over map features in specified region
  MyRegionOfInterestIterator iterator = new MyRegionOfInterestIterator();

  // configure it as needed (we assume that there is a ‘configure’ method here 
for
  // clarity purposes)
  iterator.configure();

  // return it
  return iterator;
}
If multiple tiled layers are created by the createTiledLayers method in Creating tiled layers, a different iterator might be returned for each layer (hence the layer parameter in the createTiledIterator() method), see Data tiling.