Integrating the data source

The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps89/samples/mapbuilder/index.html
To integrate the data source and map layer with the manager properties:
  1. Insert the data source into the data source tree. You first need to retrieve the data source model from the property of the manager:
    IlvMapDataSourceModel dataSourceModel =
    IlvMapDataSourceProperty.GetMapDataSourceModel(manager);
    dataSourceModel.insert(source);
    
  2. Once all data sources have been inserted, you can start loading the data source model by starting all data sources of this model recursively:
    dataSourceModel.start();
    
    Alternatively, you can start each data source when you want it by calling.
    source.start();
    
  3. You should also retrieve (and possibly set up) the map layer attached to the data source, for example:
    IlvMapLayer layer = dataSource.getInsertionLayer();
    layer.setName("name in layer tree panel");
    
    Other settings can be done at this stage, such as changing the layer style.
    layer.getStyle().setAttribute(IlvPolylineStyle.FOREGROUND,Color.black);
    layer.getStyle().setAttribute(IlvPolylineStyle.BACKGROUND,new
    Color(1,1,1,0.25f));
    
  4. Insert the layer into the map layer tree of the manager. You first need to retrieve the layer tree model from the property of the manager. Here you can arrange the layer structure by selecting the parent layer as appropriate.
    IlvMapLayerTreeModel ltm =
    IlvMapLayerTreeProperty.GetMapLayerTreeModel(manager);
    ltm.addChild(parent, layer);
    
    You can reuse the same parent layer for different data sources, possibly retrieving it from the tree model:
    IlvMapLayer parent = ltm.findChildLayer(null,"my parent");
    if(parent==null) {
      parent = new IlvMapLayer();
      parent.setName("my parent");
      IlvMapCompositeStyle parentStyle= new IlvMapCompositeStyle();
      parent.setStyle(parentStyle);
      ltm.addChild(null, parent);
    }