LayerInfos class

The LayerInfos class enables you to access each operational layer in the web map.

Caution:

The LayerInfos class is deprecated. Use the LayerStructure class instead.

AMD Module Require

require(["jimu/LayerInfos/LayerInfos"], function(LayerInfos) { /* code goes here */ });

Constructor

LayerInfos.getInstance(webmap, webmapItemInfo).then(lang.hitch(this, function(layerInfosObject){}));

.then(lang.hitch(this, function(layerInfosObject) {

}));

Creates a new layerInfos object.

Parameters:

<Object> webmap—Required. The map.

<Object> webmapItemInfo—Required. The itemInfo of the map.

Example:

require(["jimu/LayerInfos/LayerInfos "], function(LayerInfos) {
 LayerInfos.getInstance(this.map, this.map.itemInfo).then(function(layerInfosObject){
layerInfosObject.getLayerInfoArray().forEach(function(layerInfo) {
       console.log(layerInfo.title, layerInfo.id);
     });
  });
});

Methods

getLayerInfoArray()

Gets the layerInfo array corresponding to all of the operational layers.

Return type: Object[<LayerInfo> layerInfo, …]

getLayerInfoById(layerId)

Gets the layerInfo by the layer ID. Returns null if the layer ID does not exist.

Return type: <LayerInfo>

Parameters:

<String> layerId—Required. The layer ID.

getTableInfoArray()

Gets the layerInfo array corresponding to all the tables in the map.

Return type: Object[<LayerInfo> layerInfo, …]

moveDownLayer(layerId)

Moves the layer down in the map.

Return type: <String>. Returns the layer ID that has been changed.

Parameters:

<String> layerId—Required. The layer ID.

moveUpLayer(layerId)

Moves the layer up in the map.

Return type: <String>. Returns the layer ID that has been changed.

Parameters:

<String> layerId—Required. The layer ID.

traversal(callback)

Traverses all the layers and the sublayers with Depth-First-Search.

Return type: <Boolean>

Return value:

  • If true, the interrupted traversal by callback condition is satisfied.
  • If false, it traverses all the layers and sublayers, and the callback condition is not satisfied.

Parameters:

<Function> callback (layerInfo)—Required. Called by each layer and sends layerInfo as a parameter. The layer can be handled in the callback.

Callback parameters: <LayerInfo>

Callback return type: <Boolean>

Callback return value:

  • If true, it is interrupt traversal.
  • If false, it is continue traversal.

Example:

layerInfosObject.traversal(function(layerInfo) {
   console.log(layerInfo.title, layerInfo.id);
})

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.