The LayerHandler is a component that keeps track of all Layers for the MapBean, whether or not they are currently part of the map or not. It is able to dynamically add and remove layers from the list of available layers. Whether a layer is added to the MapBean depends on the visibility setting of the layer. If Layer.isVisible() is true, the layer will be added to the MapBean. There are methods within the LayerHandler that let you change the visibility setting of a layer.
The LayerHandler is able to take a Properties object, and create layers that are defined within it. The key property is "layers", which may or may not have a prefix for it. If that property does have a prefix (prefix.layers, i.e. openmap.layers), then that prefix has to be known and passed in to the contructor or init method. This layers property should fit the general openmap marker list paradigm, where the marker names are listed in a space separated list, and then each marker name is used as a prefix for the properties for a particular layer. As a minimum, each layer needs to have the class and prettyName properties defined. The class property should define the class name to use for the layer, and the prettyName property needs to be a name for the layer to be used in the GUI. Any other property that the particular layer can use should be listed in the Properties, with the applicable marker name as a prefix. Each layer should have its available properties defined in its documentation. For example:
<p/> openmap.layers=marker1 marker2 (etc) marker1.class=com.bbn.openmap.layer.GraticuleLayer marker1.prettyName=Graticule Layer # false is default marker1.addToBeanContext=false <p/> marker2.class=com.bbn.openmap.layer.shape.ShapeLayer marker2.prettyName=Political Boundaries marker2.shapeFile=pathToShapeFile marker2.spatialIndex=pathToSpatialIndexFile marker2.lineColor=FFFFFFFF marker2.fillColor=FFFF0000 <p/>
The LayerHandler is a SoloMapComponent, which means that for a particular map, there should only be one of them. When a LayerHandler is added to a BeanContext, it will look for a MapBean to connect to itself as a LayerListener so that the MapBean will receive LayerEvents - this is the mechanism that adds and removes layers on the map. If more than one MapBean is added to the BeanContext, then the last MapBean added will be added as a LayerListener, with any prior MapBeans added as a LayerListener removed from the LayerHandler. The MapHandler controls the behavior of multiple SoloMapComponent addition to the BeanContext.