TLcyLspMapComponentFactory of the
TLcyLspMapAddOn provides a way to customize the position of a new layer in a Lightspeed view.
To this end, it installs an
ILcdInitialLayerIndexProvider on the root node of the view in a Lightspeed map component.
When a new layer is added to the view, this initial layer index provider is asked to calculate the index at which to insert the new layer, allowing you to take into account all layers currently present in the view.
See the Working with layers reference guide for more information on
Default layer ordering implementation
The default initial layer index provider of a map component uses the
ILspLayer.LayerType of a layer and
ILcyModelContentType to calculate its index.
Initially, the layer type determines the layer order:
Interactive layers are put on top of background layers
Editable layers are put on top of interactive layers
Real-time layers are put on top of editable layers
This makes sense because real-time layers typically contain dynamic, continuously changing data, making them ideal candidates to be placed on top.
Background layers on the other hand contain static, non-interactive data and are preferably put below all other layers.
Finally, editable and interactive layers contain data that may be manipulated by a user. They should not be hidden behind
background layers nor cover real-time layers. See
ILspLayer.LayerType for more information about the available layer types and for what purpose each one is used.
Layers with the same layer type are ordered according to their model content type.
A layer is put on top of another layer if its model content type has a higher value than the content type of the other layer,
as defined in
For example, layers consisting of points are put on top of layers containing areas. When two layers have the same layer and
model content type, the most recently added layer is placed on top.
Take special care when dealing with instances of
ILcdLayerTreeNode. Both the layer tree node and its children belong to the view. However, only the layer tree node is directly added to the
root node of the view. Its children are indirectly added because they belong to the node. This means that only the layer tree
node receives an index from the layer index provider installed on the root node of the view. To take into account the children
of the layer tree node as well, the added layer tree node is considered, in order of preference, a real-time, editable, interactive
or background layer if one of its children is a real-time, respectively, editable, interactive or background layer. In addition,
the model content type of a layer tree node becomes
ILcyModelContentType.MIXED as soon as two of its children have a distinct model type.
A typical layer ordering scenario
In this example, we use the default
ILcdInitialLayerIndexProvider of the map component, as explained in Default layer ordering implementation. Consider an empty view, in which these layers are added sequentially:
Layer A [
ILcyModelContentType.RASTER], a raster layer representing the surface of the earth.
Layer B [
ILcyModelContentType.POINT], a vector layer representing moving airplanes.
Layer C is a layer tree node containing the following children:
Layer C1 [
ILcyModelContentType.POLYGON], a vector layer representing an airspace.
Layer C2 [
ILcyModelContentType.AREA], a terrain layer containing elevation data for the surface below the airspace region.
Layer D [
ILcyModelContentType.POLYLINE], a vector layer containing the airplane trajectories.
The view is initially empty. When layer A is added, the layer index provider assigns index 0 to it. Layer B receives index
1 because editable layers are put on top of background layers. Layer C is a layer tree node, so the index provider inspects
its children first. The node contains both an interactive (layer C1) and a background layer (layer C2). The index provider
picks the layer type from layer C1 and C2 that will make the node end up at the highest possible position in the view. The
node children also contain different model content types. Taking those things into account, the layer index provider considers
layer C an interactive layer with a mixed model content type, and inserts it in between layer A and B. Finally, when layer
D is added to the view, it is added right below layer B. They share the same layer type but points are put on top of polylines,
as defined in
Customizing the initial layer ordering
There are two ways to customize the initial layer ordering.
The first option is to keep the default layer index provider and influence the layer ordering by adapting the layer type of
a layer and/or its model content type.
This option should cover most situations.
To modify the layer type of a layer, see
To modify the model content type of a layer, use a
The second option is to implement your own layer index provider and plug it into the map component. The best way to do this
is to create your own extension of
createInitialLayerIndexProvider() and return your own implementation.
See How to modify a map component through the API ? for more information on how to modify the