> For the complete documentation index, see [llms.txt](https://developers.felt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.felt.com/js-sdk/hiding-and-showing.md).

# Hiding and showing

The Felt SDK provides methods to control the visibility of various entities like layers, layer groups, annotation groups, and legend items. These methods are designed to efficiently handle bulk operations.

## Understanding visibility requests

All visibility methods use a consistent structure that allows both showing and hiding entities in a single call:

```typescript
{
  show?: string[],  // IDs of entities to show
  hide?: string[]   // IDs of entities to hide
}
```

### Layers

Control visibility of layers using `setLayerVisibility`:

```typescript
felt.setLayerVisibility({
  show: ["layer-1", "layer-2"],
  hide: ["layer-3"]
});
```

### Layer groups

Control visibility of layer groups using `setLayerGroupVisibility`:

```typescript
felt.setLayerGroupVisibility({
  show: ["group-1", "group-2"],
  hide: ["group-3"]
});
```

### Annotation groups

Similarly, control annotation group visibility with `setElementGroupVisibility`:

```typescript
felt.setElementGroupVisibility({
  show: ["points-group"],
  hide: ["lines-group", "polygons-group"]
});
```

### Legend items

Legend items require both a layer ID and an item ID to identify them. Use `setLegendItemVisibility`:

```typescript
felt.setLegendItemVisibility({
  show: [
    { layerId: "layer-1", id: "item-1" },
    { layerId: "layer-1", id: "item-2" }
  ],
  hide: [
    { layerId: "layer-1", id: "item-3" }
  ]
});
```

## Common use cases

### Focusing on a single layer

To focus on a single layer by hiding all others, first get all layers and then use their IDs:

```typescript
const layers = await felt.getLayers();
const targetLayerId = "important-layer";

felt.setLayerVisibility({
  show: [targetLayerId],
  hide: layers
    .map(layer => layer?.id)
    .filter(id => id && id !== targetLayerId)
});
```

### Toggling visibility

When implementing a toggle, you can use empty arrays for the operation you don't need:

```typescript
function toggleLayer(layerId: string, visible: boolean) {
  felt.setLayerVisibility({
    show: visible ? [layerId] : [],
    hide: visible ? [] : [layerId]
  });
}
```

## Best practices

1. **Batch operations**: Use a single call with multiple IDs rather than making multiple calls:

```typescript
// Better approach
felt.setLayerVisibility({
  show: ["layer-1", "layer-2"],
  hide: ["layer-3", "layer-4"]
});

// Less efficient approach
felt.setLayerVisibility({ show: ["layer-1"] });
felt.setLayerVisibility({ show: ["layer-2"] });
felt.setLayerVisibility({ hide: ["layer-3"] });
felt.setLayerVisibility({ hide: ["layer-4"] });
```

2. **Omit unused properties**: When you only need to show or hide, omit the unused property rather than including it with an empty array:

```typescript
// Do this
felt.setLayerVisibility({
  show: ["layer-1"]
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.felt.com/js-sdk/hiding-and-showing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
