Geoportal Extension for Itowns API Reference

Class: LayerSwitcher

itowns.control.LayerSwitcher

Control to manage globe layers : their order, visibility and opacity, and display their informations (title, description, legends, metadata...)

new LayerSwitcher(lsOptions)

Itowns/Controls/LayerSwitcher.js, line 46
Name Type Description
lsOptions Object

control options

Name Type Description
layers Array optional

list of layers to be configured. Each array element is an object, with following properties :

Name Type Description
id String optional

ol.layer.Layer layer to be configured (that has been added to globe)

config Object optional

custom configuration object for layer information (title, description, legends, metadata, quicklook url), with following properties :

Name Type Description
title String optional

layer alias, to be displayed in widget layer list. E.g. : "Cartes IGN"

description String optional

layer description, to be displayed on title hover, or in layer information panel.

quicklookUrl String optional

link to a quick look image for this layer.

legends Array optional

array of layer legends. Each array element is an object, with following properties :
- url (String, mandatory) : link to a legend
- minScaleDenominator (Number, optional) : min scale denominator for legend validity.

metadata Array optional

array of layer metadata. Each array element is an object, with property url (String, mandatory) : link to a metadata

options Object optional

Itowns.control.Control options

Name Type Default Description
collapsed Boolean true optional

Specify if widget has to be collapsed (true) or not (false) on globe loading.

Example
var layerSwitcher = new itowns.control.LayerSwitcher({
 layers : [
     {
         id : "myLayer",
         config : {
             title : "test layer name 1",
             description : "test layer desc 1",
         }
     }
 ],
 options : {
     collapsed : false
 }
));

Extends

Methods

addLayer(layer, config)

Itowns/Controls/LayerSwitcher.js, line 261

Adds a new layer to control (when added to globe) or add new layer configuration

Name Type Description
layer Object

layer to add to layer switcher

config Object optional

additional options for layer configuration

Name Type Description
title Object optional

layer title (default is layer identifier)

description Object optional

layer description (default is null)

legends Object optional

layer legends (default is an empty array)

metadata Object optional

layer metadata (default is an empty array)

quicklookUrl Object optional

layer quicklookUrl (default is null)

Example
layerSwitcher.addLayer({
      layer : gpParcels,
      config : {
          title : "Parcelles cadastrales",
          description : "description de la couche",
          quicklookUrl : "http://quicklookUrl.fr"
      }
  })

getCollapsed(){Boolean}

Itowns/Controls/LayerSwitcher.js, line 418

Returns true if widget is collapsed (minimize), false otherwise

Returns:
collapsed

inherited getElement(){HTMLElement}

Itowns/Controls/Widget.js, line 54

Return the widget's container element.

Returns:
container element.

inherited getGlobe(){Object}

Itowns/Controls/Widget.js, line 104

Get the globe associated with the widget. Undefined if the widget is not added to a globe.

inherited getPosition(){String}

Itowns/Controls/Widget.js, line 94

Return the widget's element position.

Returns:
element position.

inherited getTarget(){HTMLElement}

Itowns/Controls/Widget.js, line 84

Return the widget's target div.

Returns:
target div.

removeLayer(layerId)

Itowns/Controls/LayerSwitcher.js, line 369

Removes a layer from control

Name Type Description
layerId Object

layer to remove to layer switcher

setCollapsed(collapsed)

Itowns/Controls/LayerSwitcher.js, line 394

Collapse or display control main container

Name Type Description
collapsed Boolean

True to collapse control, False to display it

setGlobe(globe)

Itowns/Controls/LayerSwitcher.js, line 103

Bind globe to control

Name Type Description
globe GlobeViewExtended

the globe

inherited setTarget(target, position)

Itowns/Controls/Widget.js, line 65

Associates the widget to a specified target div.

Name Type Description
target HTMLElement | String

widget target div html element or target div id.

position String

html position attribute.