HSLayers.Control.LayerSwitcher is advanced layerswitcher for OpenLayers. Basic features are following:
- Layers are organized into tree structure
You can create nest the layers simply adding / in the layer name, example:
new OpenLayers.Layer.WMS("Parent/child/Layer name",http://foo/bar);- Nodes do represent groups
Nodes in the tree structure are usually not single layers, but they are to be understand as groups of layers, covered under one hood – one tree node. In this manner, you can easily turn one layer off for specified scales, and switch other on for other scales - for user, they are represented as one single layer (but they are more). HSLayers introduces new OpenLayers.Layer.group attribute, where the name can be defined. If the attribute is not set, layer’s name is taken.
var smallMap = new OpenLayers.Layer.WMS("Small scales map", "http://foo/bar", {layers:"layer"}, { maxScale: 100000, group: "Some map" }); var bigMap = new OpenLayers.Layer.WMS("Big scales map", "http://bar/foo", {layers:"other_layer"}, { minScale: 100000, group: "Some map" }); map.addLayers([smallMap, bigMap]);Both layers will be rendered as one node in the layerswitcher with name Some map.
- LayerSwitcher indicates if the layer is visible within current scale
- Groups of layers, which is not possible to see, are gray
- Opacity settings
- You can set opacity
- legendURL, source, metadataURL
HSLayers addes new attributes to OpenLayers.Layer, namely
OpenLayers.Layer.legendURL – displays legend in the switcher
OpenLayers.Layer.source – creates download link to original data source
OpenLayers.Layer.metadataURL – creates link to layer metadata in the switcher
- User can change layer order
- Using drag&drop
HSLayers.Control.LayerSwitcher.MultiLayer is special case of LayerSwitcher, used for rendering special `HSLayers.Layer.MapServer <>`_.