LayerTreeExtra.js

Summary
LayerTreeExtra.js
Functions
mapfish. widgets. LayerTree. getNodeLayers
mapfish. widgets. LayerTree. removeNodeRemove all the OL layers from the map corresponding to a node.
mapfish. widgets. createContextualMenuPluginCreates an EXT plugin that adds a contextual menu to the layer tree.
mapfish. widgets. LayerTree. createDisableLayersPluginCreates an EXT plugin that allows to disable layers in the tree depending on current scale.

Functions

mapfish. widgets. LayerTree. getNodeLayers

mapfish.widgets.LayerTree.getNodeLayers = function(layerTree,
node)

Parameters

layerTree{<mapfish.widget.LayerTree>}
node{Ext.tree.Node} the node

Returns

{Array({<OpenLayers.Layer>})}list of OL layers impacted by a layer tree node.

mapfish. widgets. LayerTree. removeNode

mapfish.widgets.LayerTree.removeNode = function(layerTree,
node)

Remove all the OL layers from the map corresponding to a node.

Parameters

layerTree{<mapfish.widget.LayerTree>}
node{Ext.tree.Node} the layer tree node

mapfish. widgets. createContextualMenuPlugin

Creates an EXT plugin that adds a contextual menu to the layer tree.  On most browsers, this menu is shown when you right click a node.  On Opera it’s displayed when you left click a node while holding SHIFT or CTRL.

The standard options are

  • remove: allows to remove the layer
  • opacitySlide: a sub menu entry that contains a slider to change the opacity
  • opacitySlideDirect: like opacitySlide but without sub-menu
  • zoomToExtent: will zoom in or out for having the whole layer displayer in the map

Options can be added by adding them to mapfish.widgets.LayerTree.MenuFeatures

To use, add that to your LayerTree configuration

{
  xtype: 'layertree',
  ...
  plugins: [
    mapfish.widgets.LayerTree.createContextualMenuPlugin(['opacitySlide','remove'])
  ],
  ...
}

Parameters

options{Array} array of features to include

mapfish. widgets. LayerTree. createDisableLayersPlugin

mapfish.widgets.LayerTree.createDisableLayersPlugin = function(serverResolution)

Creates an EXT plugin that allows to disable layers in the tree depending on current scale.  Each node of tree can have options minScale and/or maxScale:

{
  text: 'Layer',
  layerName: 'my_layer',
  maxScale: 50000000,
  minScale: 15000000,
  children: [ ...

To use, add that to your LayerTree configuration

{
  xtype: 'layertree',
  ...
  plugins: [
    mapfish.widgets.LayerTree.createDisableLayersPlugin(myMap)
  ],
  ...
}

Parameters

serverResolution{Integer} mapfile resolution (in order to adjust scales)

Returns

{Object}EXT plugin
mapfish.widgets.LayerTree.getNodeLayers = function(layerTree,
node)
mapfish.widgets.LayerTree.removeNode = function(layerTree,
node)
Remove all the OL layers from the map corresponding to a node.
mapfish.widgets.LayerTree.createDisableLayersPlugin = function(serverResolution)
Creates an EXT plugin that allows to disable layers in the tree depending on current scale.
Close