Skip to main content
Version: 0.7.3

Working with Layers

Add a Layer

Using addLayer(...) function you can add a new layer to the map.

To learn about configuring a specific layer programmatically, visit the Layer Format Reference.

The dataset specified in dataId must be added to the map in advance. In this example we already added a dataset to the map.

UnfoldedMap.addLayer(spec: LayerSpec): void
type LayerSpec = {
id: string;
type: string;
config: LayerConfig;
visualChannels?: Record<string, VisualChannel>;
};
type LayerConfig = {
dataId: string;
label?: string;
columns: object;
isVisible?: boolean;
visConfig?: object;
};

Parameters

  • NameDescription
    id string
    Unique identifier of the layer
    config.dataId string
    Dataset id
    config.label string
    (Optional) Layer name
    config.isVisible booleandefault: true
    (Optional) If true Studio will attempt to create layers automatically

Set Layer Visibility

While you can set the initial visibility when adding the layer, you can always toggle the visibility of the already added layers using the setLayerVisibility(...) function.

UnfoldedMap.setLayerVisibility(layerId: string, isVisible: boolean): void

Parameters

  • NameDescription
    id string
    Unique identifier of the layer
    isVisible boolean
    Layer visibility

Get Available Layers

Returns the label, id and visibility (isVisible) for each layer that is available on the map.

UnfoldedMap.getLayers(): Promise<Layer[]>
interface Layer {
label: string;
id: string;
isVisible: boolean;
}

Remove Layers

Using removeLayer(...) function you can add a remove an existing layer from the map.

UnfoldedMap.removeLayer(id: string): void

Parameters

  • NameDescription
    id string
    Unique identifier of the layer