LayerFilterAPI

Interface LayerFilterAPI

The LayerFilterAPI is used to manage the visibility of layers and filter them. These are additional metadata information from input data and are not always provided.

The LayerFilterAPI provides methods to:

  • Retrieve the list of available layer filters and their states.
  • Enable or disable specific layer filters.
  • Check if a specific node is part of an enabled layer filter.

This functionality is particularly useful for managing the visualization of complex models by toggling the visibility of specific layer filters based on user preferences or application logic.

To use the LayerFilterAPI, layer filters can be accessed via the context:

// Get the webvis context
const context = webvis.getContext();

context.getRegisteredLayerFilters();
// -> example: {DEFAULT: false, LAYER1: false}

// Enable a layer filter
context.setLayerFilterEnabled('LAYER1', true);
// -> example: {layerFilterName: 'LAYER1', value: true, hasChanged: true}

context.getEnabledLayerFilters();
// -> example: ['LAYER1']

context.getRegisteredLayerFilters();
// -> example: {DEFAULT: false, LAYER1: true}

// Check if a node is part of an enabled layer
await context.isNodePartOfEnabledLayers(nodeID);
// -> example: true

The following events are associated with the LayerFilterAPI:

interface LayerFilterAPI {
    getEnabledLayerFilters(): string[];
    getRegisteredLayerFilters(): { [key: string]: boolean };
    isNodePartOfEnabledLayers(nodeID: number): Promise<boolean>;
    setLayerFilterEnabled(
        name: string,
        enabled: boolean,
    ): SetLayerFilterEnabledResult;
}

Hierarchy (View Summary)

Methods

  • Returns the currently defined list of enabled layer filters.

    Returns string[]

    An array of strings representing the names of the enabled layer filters.

  • Returns the currently defined list of layer filters with their current state.

    Returns { [key: string]: boolean }

    Returns a map of the registered layer filters and their states.

  • Returns true if the specified node ID is part of an enabled layer.

    Parameters

    • nodeID: number

      The node ID which should be checked.

    Returns Promise<boolean>

    Returns a promise that resolves to true if the node is part of an enabled layer, false otherwise.