Class: GoOwnToc

GoOwnToc

Manages the Table of Contents (TOC) for a specific map, including handling layer visibility and custom legends.

new GoOwnToc()

Toc/GoOwnToc.ts, line 63

Methods

addLayer(idLayer)

Toc/GoOwnToc.ts, line 1304

Adds a single layer back to the TOC and activates its legend entry. This method is typically used to restore a previously removed layer.

WORKFLOW:

  1. Activates the layer's legend entry if it exists
  2. Finds the layer in the TOC structure and marks it as active
  3. Sets the layer visibility and rebuilds the TOC structure
Name Type Description
idLayer string

ID of the layer to add back to the TOC

addLayerLegend(idLayer)

Toc/GoOwnToc.ts, line 1333

Adds a specific layer to the legend display only. If the layer is found in the legend and is currently inactive, it will be activated and the entire layer will be added back to the TOC.

Name Type Description
idLayer string

ID of the layer to add to legend display

addLayers(idLayers)

Toc/GoOwnToc.ts, line 1354

Adds multiple layers back to the TOC structure in a batch operation. This method is more efficient than calling addLayer() multiple times. Note: This method does NOT automatically rebuild the TOC structure - you should call createTocStructure() after if needed.

Name Type Description
idLayers Array.<string>

Array of layer IDs to add back to TOC

addLayersLegend(idLayers)

Toc/GoOwnToc.ts, line 1388

This function allows you add a group of layers from the legend

Name Type Description
idLayers Array.<string>

Array of layers to add

addNewLayer(layerConfig){void}

Toc/GoOwnToc.ts, line 1373

Adds a new layer to the TOC and updates the configuration.

Name Type Description
layerConfig types.layerOptions

The configuration object for the new layer to be added.

Returns:
Type Description
void

cleanArrFolder(arrFolder)

Toc/GoOwnToc.ts, line 659

This function returns a cleaned array without empty elements

Name Type Description
arrFolder Array.<string>

Array of URL splitted by '/'

createCustomLegend(mapID, customLegendElement){GoCustomLegend}

Toc/GoOwnToc.ts, line 1475

Creates a custom legend for the map and associates it with the TOC.

Name Type Description
mapID string

The ID of the map for which the custom legend is created.

customLegendElement HTMLDivElement

The HTML div element that represents the custom legend.

Returns:
Type Description
GoCustomLegend The created GoCustomLegend instance.

createStageToc(config)

Toc/GoOwnToc.ts, line 174

Initializes the TOC structure based on the provided configuration. This method creates the complete TOC and legend structure from the config.json file.

IMPORTANT: Base layers should NOT be included in legends, so they are filtered out during legend creation.

Name Type Description
config any

The map configuration object containing layer and TOC settings

createTocStructure(stageToc)

Toc/GoOwnToc.ts, line 351

This function creates HTML structure taking in account the stageToc generated in previous step

Name Type Description
stageToc module:types~ownToc

TOC configuration variable

getFolderId(urlFolder)

Toc/GoOwnToc.ts, line 572

This function returns the folder id of any layer defined in config file

Name Type Description
urlFolder string

URL of folder defined in config file

getFolderName(urlFolder)

Toc/GoOwnToc.ts, line 610

This function returns the folder name of any layer defined in config file

Name Type Description
urlFolder string

URL of folder defined in config file

getLanguage()

Toc/GoOwnToc.ts, line 1128

This function allows you get the language in TOC

getSubFolderId(subFolderName)

Toc/GoOwnToc.ts, line 646

This function creates the id string for any subfolder

Name Type Description
subFolderName string

Name of subfolder defined in config file

getSubFolderName(urlFolder)

Toc/GoOwnToc.ts, line 631

This function returns the subfolder name of any layer defined in config file

Name Type Description
urlFolder string

URL of folder defined in config file

getTextFolderId(txtfolder)

Toc/GoOwnToc.ts, line 621

This function creates the id string

Name Type Description
txtfolder string

Name of folder defined in config file

getTheme()

Toc/GoOwnToc.ts, line 1152

This function allows you get the theme of TOC

hasEvent(eventName){boolean}

Toc/GoOwnToc.ts, line 1515

Checks if there are any listeners registered for the specified event.

Name Type Description
eventName string

The name of the event to check for listeners.

Returns:
Type Description
boolean True if there are listeners for the event, false otherwise.

loadOwnTocBody()

Toc/GoOwnToc.ts, line 696

This function creates HTML structure of TOC Body

loadOwnTocHeader(hasLegend)

Toc/GoOwnToc.ts, line 674

This function creates HTML structure of TOC Header

Name Type Description
hasLegend boolean

Flag to indicate if TOC also shows Legends

off(eventName, callback){void}

Toc/GoOwnToc.ts, line 1506

Removes an event listener for the specified event.

Name Type Description
eventName string optional

The name of the event to remove listeners for. Optional.

callback function optional

The specific function to remove from the event's listeners. Optional.

Returns:
Type Description
void

on(eventName, callback){void}

Toc/GoOwnToc.ts, line 1486

Registers an event listener for the specified event.

Name Type Description
eventName string

The name of the event to listen for.

callback function

The function to be called when the event is emitted.

Returns:
Type Description
void

once(eventName, callback){void}

Toc/GoOwnToc.ts, line 1496

Registers a one-time event listener for the specified event.

Name Type Description
eventName string

The name of the event to listen for once.

callback function

The function to be called when the event is emitted.

Returns:
Type Description
void

orderStageTocBySubFolder(stageToc)

Toc/GoOwnToc.ts, line 1036

This function orders the subfoders of the TOC by name

Name Type Description
stageToc module:types~ownToc

TOC configuration variable

reload()

Toc/GoOwnToc.ts, line 1408

This function reload the toc from original config

reloadFolderVisibility()

Toc/GoOwnToc.ts, line 1094

Updates folder visibility based on the visibility state of their contained layers. A folder is visible only if ALL its layers are visible. This method is typically called after batch layer visibility changes.

removeFolderFromToc(stageToc){boolean}

Toc/GoOwnToc.ts, line 106

Removes empty folders from the TOC and manages legend visibility based on active layers. This function is called after layer operations to clean up the TOC structure.

IMPORTANT: Base layers should NEVER appear in legends, so they are excluded from legend calculations.

Name Type Description
stageToc types.ownToc

The TOC structure containing layers and legends

Returns:
Type Description
boolean Returns true when all non-base layers are inactive

removeLayer(idLayer)

Toc/GoOwnToc.ts, line 1190

Removes a single layer from the TOC and its corresponding legend entry. This method handles both the layer visibility in the TOC structure and the legend cleanup.

WORKFLOW:

  1. Sets layer visibility to true (hide it visually)
  2. Marks the layer as inactive in the TOC structure
  3. Deactivates the layer's legend entry
  4. Checks if the legend group should remain active (if other layers still have active legends)
  5. Cleans up empty folders and rebuilds the TOC structure
Name Type Description
idLayer string

ID of the layer to remove from TOC and legend

removeLayerLegend(idLayer)

Toc/GoOwnToc.ts, line 1236

Removes a specific layer from the legend only (not from the TOC structure). This method only affects the legend display, leaving the layer active in the TOC.

Name Type Description
idLayer string

ID of the layer to remove from legend display

removeLayers(idLayers)

Toc/GoOwnToc.ts, line 1256

Removes multiple layers from the TOC structure in a batch operation. This method is more efficient than calling removeLayer() multiple times. Note: This method does NOT automatically rebuild the TOC structure - you should call createTocStructure() after if needed.

Name Type Description
idLayers Array.<string>

Array of layer IDs to remove from TOC

removeLayersLegend(idLayers)

Toc/GoOwnToc.ts, line 1277

Removes multiple layers from the legend display in a batch operation. This affects only the legend visibility, not the TOC structure.

Name Type Description
idLayers Array.<string>

Array of layer IDs to remove from legend

setHeightOwnToc(ownToc_container, stageToc)

Toc/GoOwnToc.ts, line 1027

This function defines the maximum height of TOC container DIV regarding the config variable

Name Type Description
ownToc_container HTMLDivElement

Element HTML of TOC container

stageToc module:types~ownToc

TOC configuration variable

setLanguage(idLanguage)

Toc/GoOwnToc.ts, line 1137

This function allows you specify the language in TOC

Name Type Description
idLanguage languages

id of the language for the TOC elements

setTheme(theme)

Toc/GoOwnToc.ts, line 1161

This function allows you specify the theme in TOC

Name Type Description
theme constants.themes

id of the theme for the TOC

setVisibility(idLayer, visibility, reload)

Toc/GoOwnToc.ts, line 1061

Sets the visibility state of a specific layer in the TOC. This method updates the layer's visible property and optionally rebuilds the TOC structure.

BEHAVIOR:

  • If the layer is already in the requested visibility state, no action is taken
  • If reload is true (default), the TOC structure will be rebuilt after the change
  • Emits a LAYER_CHANGE_VISIBILITY event after the operation
Name Type Description
idLayer string

ID of the layer to modify

visibility boolean

New visibility state for the layer

reload boolean

Whether to rebuild TOC structure after change (default: true)

setVisibilityLayers(idLayers, visibility)

Toc/GoOwnToc.ts, line 1115

Sets the visibility state for multiple layers in a batch operation. This method is more efficient than calling setVisibility() multiple times as it only rebuilds the TOC structure once at the end.

Name Type Description
idLayers Array.<string>

Array of layer IDs to modify

visibility boolean

New visibility state for all specified layers

GoOwnToc

new GoOwnToc(id, goMap)

Toc/GoOwnToc.ts, line 75

Initializes the GoOwnToc instance with a TOC ID and a map instance.

Name Type Description
id string

The unique identifier for the TOC.

goMap GoMap

The map instance associated with this TOC.

Methods

addLayer(idLayer)

Toc/GoOwnToc.ts, line 1304

Adds a single layer back to the TOC and activates its legend entry. This method is typically used to restore a previously removed layer.

WORKFLOW:

  1. Activates the layer's legend entry if it exists
  2. Finds the layer in the TOC structure and marks it as active
  3. Sets the layer visibility and rebuilds the TOC structure
Name Type Description
idLayer string

ID of the layer to add back to the TOC

addLayerLegend(idLayer)

Toc/GoOwnToc.ts, line 1333

Adds a specific layer to the legend display only. If the layer is found in the legend and is currently inactive, it will be activated and the entire layer will be added back to the TOC.

Name Type Description
idLayer string

ID of the layer to add to legend display

addLayers(idLayers)

Toc/GoOwnToc.ts, line 1354

Adds multiple layers back to the TOC structure in a batch operation. This method is more efficient than calling addLayer() multiple times. Note: This method does NOT automatically rebuild the TOC structure - you should call createTocStructure() after if needed.

Name Type Description
idLayers Array.<string>

Array of layer IDs to add back to TOC

addLayersLegend(idLayers)

Toc/GoOwnToc.ts, line 1388

This function allows you add a group of layers from the legend

Name Type Description
idLayers Array.<string>

Array of layers to add

addNewLayer(layerConfig){void}

Toc/GoOwnToc.ts, line 1373

Adds a new layer to the TOC and updates the configuration.

Name Type Description
layerConfig types.layerOptions

The configuration object for the new layer to be added.

Returns:
Type Description
void

cleanArrFolder(arrFolder)

Toc/GoOwnToc.ts, line 659

This function returns a cleaned array without empty elements

Name Type Description
arrFolder Array.<string>

Array of URL splitted by '/'

createCustomLegend(mapID, customLegendElement){GoCustomLegend}

Toc/GoOwnToc.ts, line 1475

Creates a custom legend for the map and associates it with the TOC.

Name Type Description
mapID string

The ID of the map for which the custom legend is created.

customLegendElement HTMLDivElement

The HTML div element that represents the custom legend.

Returns:
Type Description
GoCustomLegend The created GoCustomLegend instance.

createStageToc(config)

Toc/GoOwnToc.ts, line 174

Initializes the TOC structure based on the provided configuration. This method creates the complete TOC and legend structure from the config.json file.

IMPORTANT: Base layers should NOT be included in legends, so they are filtered out during legend creation.

Name Type Description
config any

The map configuration object containing layer and TOC settings

createTocStructure(stageToc)

Toc/GoOwnToc.ts, line 351

This function creates HTML structure taking in account the stageToc generated in previous step

Name Type Description
stageToc module:types~ownToc

TOC configuration variable

getFolderId(urlFolder)

Toc/GoOwnToc.ts, line 572

This function returns the folder id of any layer defined in config file

Name Type Description
urlFolder string

URL of folder defined in config file

getFolderName(urlFolder)

Toc/GoOwnToc.ts, line 610

This function returns the folder name of any layer defined in config file

Name Type Description
urlFolder string

URL of folder defined in config file

getLanguage()

Toc/GoOwnToc.ts, line 1128

This function allows you get the language in TOC

getSubFolderId(subFolderName)

Toc/GoOwnToc.ts, line 646

This function creates the id string for any subfolder

Name Type Description
subFolderName string

Name of subfolder defined in config file

getSubFolderName(urlFolder)

Toc/GoOwnToc.ts, line 631

This function returns the subfolder name of any layer defined in config file

Name Type Description
urlFolder string

URL of folder defined in config file

getTextFolderId(txtfolder)

Toc/GoOwnToc.ts, line 621

This function creates the id string

Name Type Description
txtfolder string

Name of folder defined in config file

getTheme()

Toc/GoOwnToc.ts, line 1152

This function allows you get the theme of TOC

hasEvent(eventName){boolean}

Toc/GoOwnToc.ts, line 1515

Checks if there are any listeners registered for the specified event.

Name Type Description
eventName string

The name of the event to check for listeners.

Returns:
Type Description
boolean True if there are listeners for the event, false otherwise.

loadOwnTocBody()

Toc/GoOwnToc.ts, line 696

This function creates HTML structure of TOC Body

loadOwnTocHeader(hasLegend)

Toc/GoOwnToc.ts, line 674

This function creates HTML structure of TOC Header

Name Type Description
hasLegend boolean

Flag to indicate if TOC also shows Legends

off(eventName, callback){void}

Toc/GoOwnToc.ts, line 1506

Removes an event listener for the specified event.

Name Type Description
eventName string optional

The name of the event to remove listeners for. Optional.

callback function optional

The specific function to remove from the event's listeners. Optional.

Returns:
Type Description
void

on(eventName, callback){void}

Toc/GoOwnToc.ts, line 1486

Registers an event listener for the specified event.

Name Type Description
eventName string

The name of the event to listen for.

callback function

The function to be called when the event is emitted.

Returns:
Type Description
void

once(eventName, callback){void}

Toc/GoOwnToc.ts, line 1496

Registers a one-time event listener for the specified event.

Name Type Description
eventName string

The name of the event to listen for once.

callback function

The function to be called when the event is emitted.

Returns:
Type Description
void

orderStageTocBySubFolder(stageToc)

Toc/GoOwnToc.ts, line 1036

This function orders the subfoders of the TOC by name

Name Type Description
stageToc module:types~ownToc

TOC configuration variable

reload()

Toc/GoOwnToc.ts, line 1408

This function reload the toc from original config

reloadFolderVisibility()

Toc/GoOwnToc.ts, line 1094

Updates folder visibility based on the visibility state of their contained layers. A folder is visible only if ALL its layers are visible. This method is typically called after batch layer visibility changes.

removeFolderFromToc(stageToc){boolean}

Toc/GoOwnToc.ts, line 106

Removes empty folders from the TOC and manages legend visibility based on active layers. This function is called after layer operations to clean up the TOC structure.

IMPORTANT: Base layers should NEVER appear in legends, so they are excluded from legend calculations.

Name Type Description
stageToc types.ownToc

The TOC structure containing layers and legends

Returns:
Type Description
boolean Returns true when all non-base layers are inactive

removeLayer(idLayer)

Toc/GoOwnToc.ts, line 1190

Removes a single layer from the TOC and its corresponding legend entry. This method handles both the layer visibility in the TOC structure and the legend cleanup.

WORKFLOW:

  1. Sets layer visibility to true (hide it visually)
  2. Marks the layer as inactive in the TOC structure
  3. Deactivates the layer's legend entry
  4. Checks if the legend group should remain active (if other layers still have active legends)
  5. Cleans up empty folders and rebuilds the TOC structure
Name Type Description
idLayer string

ID of the layer to remove from TOC and legend

removeLayerLegend(idLayer)

Toc/GoOwnToc.ts, line 1236

Removes a specific layer from the legend only (not from the TOC structure). This method only affects the legend display, leaving the layer active in the TOC.

Name Type Description
idLayer string

ID of the layer to remove from legend display

removeLayers(idLayers)

Toc/GoOwnToc.ts, line 1256

Removes multiple layers from the TOC structure in a batch operation. This method is more efficient than calling removeLayer() multiple times. Note: This method does NOT automatically rebuild the TOC structure - you should call createTocStructure() after if needed.

Name Type Description
idLayers Array.<string>

Array of layer IDs to remove from TOC

removeLayersLegend(idLayers)

Toc/GoOwnToc.ts, line 1277

Removes multiple layers from the legend display in a batch operation. This affects only the legend visibility, not the TOC structure.

Name Type Description
idLayers Array.<string>

Array of layer IDs to remove from legend

setHeightOwnToc(ownToc_container, stageToc)

Toc/GoOwnToc.ts, line 1027

This function defines the maximum height of TOC container DIV regarding the config variable

Name Type Description
ownToc_container HTMLDivElement

Element HTML of TOC container

stageToc module:types~ownToc

TOC configuration variable

setLanguage(idLanguage)

Toc/GoOwnToc.ts, line 1137

This function allows you specify the language in TOC

Name Type Description
idLanguage languages

id of the language for the TOC elements

setTheme(theme)

Toc/GoOwnToc.ts, line 1161

This function allows you specify the theme in TOC

Name Type Description
theme constants.themes

id of the theme for the TOC

setVisibility(idLayer, visibility, reload)

Toc/GoOwnToc.ts, line 1061

Sets the visibility state of a specific layer in the TOC. This method updates the layer's visible property and optionally rebuilds the TOC structure.

BEHAVIOR:

  • If the layer is already in the requested visibility state, no action is taken
  • If reload is true (default), the TOC structure will be rebuilt after the change
  • Emits a LAYER_CHANGE_VISIBILITY event after the operation
Name Type Description
idLayer string

ID of the layer to modify

visibility boolean

New visibility state for the layer

reload boolean

Whether to rebuild TOC structure after change (default: true)

setVisibilityLayers(idLayers, visibility)

Toc/GoOwnToc.ts, line 1115

Sets the visibility state for multiple layers in a batch operation. This method is more efficient than calling setVisibility() multiple times as it only rebuilds the TOC structure once at the end.

Name Type Description
idLayers Array.<string>

Array of layer IDs to modify

visibility boolean

New visibility state for all specified layers