0.0.40 • Published 5 months ago

@icgcat/layer-tree v0.0.40

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
5 months ago

License Version LinkedIn

@icgcat/layer-tree

This component is an implementation of an interactive WMS layer management system using toggles to activate and deactivate layers and sublayers. It is useful for applications that need to manage layer hierarchies, such as map viewers.

Features

  • Support for nested layers: Each main layer can have sublayers that can also be managed with toggles.
  • Highly customizable: Supports configurations for colors, fieldset border radius, and colors for parent and child layer toggles.
  • Interaction with store: Uses a Svelte store to maintain the visibility state of sublayers.
  • Callbacks: Allows a custom onSelect function to manage logic when layers are toggled.

Configurable Properties

This component supports the following configurable properties:

PropertyDescriptionDefault Value
checkedInitial state of the toggle (true/false).false
onSelectFunction executed when a toggle changes state.null
dataTypeType of data managed (currently only WMS)."WMS"
dataFileArrayArray of objects with information about layers and sublayers.[]
fontColorFont color of the labels."black"
fieldsetBorderColorBorder color of the fieldset.""
fieldsetBorderRadiusCorner radius of the fieldset."5px"
parentToggleColorColor of the toggle for main layers."green"
childrenToggleColorColor of the toggle for sublayers."red"

Usage Example

<script>
  import { LayerTree } from "@icgcat/layer-tree";

  const dataFileArray = [
    {
      title: "Main Layer",
      layers: [
        {
          title: "Sublayer 1",
          state: true,
          layers: [
            { title: "Sublayer 1.1", state: false },
            { title: "Sublayer 1.2", state: true }
          ]
        },
        {
          title: "Sublayer 2",
          state: false
        }
      ]
    }
  ];

  function handleSelect(state, layer) {
    console.log("Toggle changed:", state, layer);
  }
</script>

<LayerTree
  dataFileArray={dataFileArray}
  fontColor="blue"
  fieldsetBorderColor="gray"
  fieldsetBorderRadius="10px"
  parentToggleColor="green"
  childrenToggleColor="orange"
  onSelect={handleSelect}
/>

Dependencies

This component uses:

  • Svelte: Main framework.
  • @icgcat/ui: Component library for the toggle.
  • Svelte Store: To manage the global visibility state of sublayers.

Customization

Styling

The component supports styling via properties like fontColor, fieldsetBorderColor, and fieldsetBorderRadius. You can also change the colors of toggles for main and sublayers via parentToggleColor and childrenToggleColor.

Interactivity

The onSelect function can be used to execute custom code when toggles change state, providing flexibility to integrate this component into more complex applications.

Developed by:

License

This project is licensed under the MIT License.

0.0.40

5 months ago

0.0.30

8 months ago

0.0.29

8 months ago

0.0.28

8 months ago

0.0.27

8 months ago

0.0.26

8 months ago

0.0.25

9 months ago

0.0.24

9 months ago

0.0.23

9 months ago

0.0.22

9 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago

0.0.18

9 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago