# FeltController

***

This is the main interface for interacting with a Felt map.

This interface is composed of the various controllers, each having a different area of responsibility.

All the methods are listed here, but each controller is documented on its own to make it easier to find related methods and events.

## Extends

* [`ViewportController`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportcontroller).[`UiController`](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller).[`LayersController`](https://developers.felt.com/js-sdk-api-reference/layers/layerscontroller).[`ElementsController`](https://developers.felt.com/js-sdk-api-reference/elements/elementscontroller).[`SelectionController`](https://developers.felt.com/js-sdk-api-reference/selection/selectioncontroller).[`InteractionsController`](https://developers.felt.com/js-sdk-api-reference/interactions/interactionscontroller).[`ToolsController`](https://developers.felt.com/js-sdk-api-reference/tools/toolscontroller).[`MiscController`](https://developers.felt.com/js-sdk-api-reference/misc/misccontroller).[`BasemapsController`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemapscontroller)

## Methods

### getCurrentBasemap()

> **getCurrentBasemap**(): `Promise`<[`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)>

Gets the currently active basemap.

Use this method to retrieve information about the current basemap, including its type (Felt, color, or custom tile), name, color scheme, and attribution.

#### Returns

`Promise`<[`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)>

A promise that resolves to the current basemap configuration.

#### Example

```typescript
// Get current basemap
const basemap = await felt.getCurrentBasemap();
console.log({
  name: basemap.name,
  type: basemap.type,
  uiColorScheme: basemap.uiColorScheme,
});
```

***

### getBasemaps()

> **getBasemaps**(): `Promise`<[`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)\[]>

Gets all basemaps available on the map.

Use this method to retrieve a list of all available basemaps that can be applied to the map.

#### Returns

`Promise`<[`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)\[]>

A promise that resolves to all basemaps available on the map.

#### Example

```typescript
// Get all available basemaps
const basemaps = await felt.getBasemaps();
const lightBasemaps = basemaps.filter(b => b.uiColorScheme === "light");
```

***

### chooseBasemap()

> **chooseBasemap**(`id`: `string`): `void`

Chooses the basemap to use for the map.

Use this method to change the current basemap. The basemap ID can be obtained from getBasemaps().

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `id`      | `string` |

#### Returns

`void`

A promise that resolves when the basemap has been set.

#### Example

```typescript
// Switch to a specific basemap
const basemaps = await felt.getBasemaps();
const darkBasemap = basemaps.find(b => b.uiColorScheme === "dark");
if (darkBasemap) {
  await felt.chooseBasemap(darkBasemap.id);
}
```

***

### addCustomBasemap()

> **addCustomBasemap**(`args`: { `basemap`: [`ColorBasemapInput`](https://developers.felt.com/js-sdk-api-reference/basemaps/colorbasemapinput) | [`CustomTileBasemapInput`](https://developers.felt.com/js-sdk-api-reference/basemaps/customtilebasemapinput); `select`: `boolean`; }): `Promise`<[`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)>

Adds a custom basemap to the map. This can be either a solid color or a basemap from a custom tile URL.

#### Parameters

| Parameter      | Type                                                                                                                                                                                                                                                    | Description                                    |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
| `args`         | { `basemap`: [`ColorBasemapInput`](https://developers.felt.com/js-sdk-api-reference/basemaps/colorbasemapinput) \| [`CustomTileBasemapInput`](https://developers.felt.com/js-sdk-api-reference/basemaps/customtilebasemapinput); `select`: `boolean`; } | -                                              |
| `args.basemap` | [`ColorBasemapInput`](https://developers.felt.com/js-sdk-api-reference/basemaps/colorbasemapinput) \| [`CustomTileBasemapInput`](https://developers.felt.com/js-sdk-api-reference/basemaps/customtilebasemapinput)                                      | The basemap to add.                            |
| `args.select`? | `boolean`                                                                                                                                                                                                                                               | Whether to select the basemap after adding it. |

#### Returns

`Promise`<[`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)>

A promise for the added basemap.

#### Example

```typescript
// Add a custom basemap and select it
await felt.addCustomBasemap({
  basemap: {
    type: "xyz_tile",
    tileUrl: "https://example.com/tile.png"
  },
  select: true,
});
```

***

### removeBasemap()

> **removeBasemap**(`id`: `string`): `Promise`<`void`>

Removes a basemap from the list of available basemaps.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `id`      | `string` |

#### Returns

`Promise`<`void`>

A promise that resolves when the basemap has been removed.

***

### getElement()

> **getElement**(`id`: `string`): `Promise`<`null` | [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element)>

Get a single element from the map by its id.

Use this method when you know the specific ID of an element and want to retrieve its current state. This is more efficient than getting all elements and filtering.

#### Parameters

| Parameter | Type     | Description                            |
| --------- | -------- | -------------------------------------- |
| `id`      | `string` | The id of the element you want to get. |

#### Returns

`Promise`<`null` | [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element)>

A promise that resolves to the requested element, or `null` if not found.

#### Example

```typescript
const element = await felt.getElement("element-1");
```

***

### getElementGeometry()

> **getElementGeometry**(`id`: `string`): `Promise`<`null` | [`GeoJsonGeometry`](https://developers.felt.com/js-sdk-api-reference/shared/geojsongeometry)>

Get the geometry of an element in GeoJSON geometry format.

For most element types, the geometry returned is based on the `coordinates` property of the element, with some differences:

* For Circle elements, the geometry is a Polygon drawn from the `center` and `radius` properties.
* Path elements become MultiLineString geometries.
* Marker elements return a MultiLineString of the path traced by the user as they drew the marker. Note that this is not the polygon formed by filled-in "pen" stroke, which doesn't exactly follow the path traced by the user as it is smoothed and interpolated to create a continuous line.
* Text, Note and Image elements do not return geometry, so will return `null`.

Use this method when you need the geometric representation of an element for spatial analysis or visualization purposes.

#### Parameters

| Parameter | Type     | Description                                            |
| --------- | -------- | ------------------------------------------------------ |
| `id`      | `string` | The id of the element you want to get the geometry of. |

#### Returns

`Promise`<`null` | [`GeoJsonGeometry`](https://developers.felt.com/js-sdk-api-reference/shared/geojsongeometry)>

A promise that resolves to the element's geometry in GeoJSON format, or `null` if the element has no geometry.

#### Example

```typescript
const geometry = await felt.getElementGeometry("element-1");
console.log(geometry?.type, geometry?.coordinates);
```

***

### getElements()

> **getElements**(`constraint`?: [`GetElementsConstraint`](https://developers.felt.com/js-sdk-api-reference/elements/getelementsconstraint)): `Promise`<(`null` | [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element))\[]>

Gets elements from the map, according to the constraints supplied. If no constraints are supplied, all elements will be returned.

Use this method to retrieve multiple elements, optionally filtered by constraints. This is useful for bulk operations or when you need to analyze all elements on the map.

#### Parameters

| Parameter     | Type                                                                                                       | Description                                                          |
| ------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `constraint`? | [`GetElementsConstraint`](https://developers.felt.com/js-sdk-api-reference/elements/getelementsconstraint) | Optional constraints to apply to the elements returned from the map. |

#### Returns

`Promise`<(`null` | [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element))\[]>

A promise that resolves to an array of elements, ordered by the order specified in Felt.

#### Remarks

The elements in the map, ordered by the order specified in Felt. This is not necessarily the order that they are drawn in, as Felt draws points above lines and lines above polygons, for instance.

#### Example

```typescript
const elements = await felt.getElements();
```

***

### getElementGroup()

> **getElementGroup**(`id`: `string`): `Promise`<`null` | [`ElementGroup`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroup)>

Get an element group from the map by its id.

Element groups allow you to organize related elements together and control their visibility as a unit.

#### Parameters

| Parameter | Type     | Description                                  |
| --------- | -------- | -------------------------------------------- |
| `id`      | `string` | The id of the element group you want to get. |

#### Returns

`Promise`<`null` | [`ElementGroup`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroup)>

A promise that resolves to the requested element group, or `null` if not found.

#### Example

```typescript
const elementGroup = await felt.getElementGroup("element-group-1");
```

***

### getElementGroups()

> **getElementGroups**(`constraint`?: [`GetElementGroupsConstraint`](https://developers.felt.com/js-sdk-api-reference/elements/getelementgroupsconstraint)): `Promise`<(`null` | [`ElementGroup`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroup))\[]>

Gets element groups from the map, according to the filters supplied. If no constraints are supplied, all element groups will be returned in rendering order.

Use this method to retrieve multiple element groups, optionally filtered by constraints. This is useful for bulk operations on element groups.

#### Parameters

| Parameter     | Type                                                                                                                 | Description                                                                |
| ------------- | -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `constraint`? | [`GetElementGroupsConstraint`](https://developers.felt.com/js-sdk-api-reference/elements/getelementgroupsconstraint) | Optional constraints to apply to the element groups returned from the map. |

#### Returns

`Promise`<(`null` | [`ElementGroup`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroup))\[]>

A promise that resolves to an array of element groups in rendering order.

#### Example

```typescript
const elementGroups = await felt.getElementGroups({ ids: ["element-group-1", "element-group-2"] });
```

***

### setElementGroupVisibility()

> **setElementGroupVisibility**(`visibility`: [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest)): `Promise`<`void`>

Hide or show element groups with the given ids.

Use this method to control the visibility of multiple element groups at once. This is more efficient than hiding/showing individual elements.

#### Parameters

| Parameter    | Type                                                                                                   | Description                                      |
| ------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------ |
| `visibility` | [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest) | The visibility configuration for element groups. |

#### Returns

`Promise`<`void`>

A promise that resolves when the visibility changes are applied.

#### Example

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

***

### createElement()

> **createElement**(`element`: [`ElementCreate`](https://developers.felt.com/js-sdk-api-reference/elements/elementcreate)): `Promise`<[`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element)>

Create a new element on the map.

Use this method to programmatically create elements on the map. Elements created via the SDK are only available to the current session and are not persisted.

#### Parameters

| Parameter | Type                                                                                       | Description                          |
| --------- | ------------------------------------------------------------------------------------------ | ------------------------------------ |
| `element` | [`ElementCreate`](https://developers.felt.com/js-sdk-api-reference/elements/elementcreate) | The element configuration to create. |

#### Returns

`Promise`<[`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element)>

A promise that resolves to the created element.

#### Example

```typescript
const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
```

***

### updateElement()

> **updateElement**(`element`: [`ElementUpdate`](https://developers.felt.com/js-sdk-api-reference/elements/elementupdate)): `Promise`<[`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element)>

Update an element on the map. The element type must be specified.

Use this method to modify existing elements. You can update properties like coordinates, styling, and metadata.

#### Parameters

| Parameter | Type                                                                                       | Description                       |
| --------- | ------------------------------------------------------------------------------------------ | --------------------------------- |
| `element` | [`ElementUpdate`](https://developers.felt.com/js-sdk-api-reference/elements/elementupdate) | The element update configuration. |

#### Returns

`Promise`<[`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element)>

A promise that resolves to the updated element.

#### Example

```typescript
// Update a place element's coordinates
await felt.updateElement({
  id: "element-1",
  type: "Place",
  coordinates: [10, 20]
});

// Update a polygon's style
await felt.updateElement({
  id: "element-2",
  type: "Polygon",
  color: "#ABC123",
  fillOpacity: 0.5
});
```

***

### deleteElement()

> **deleteElement**(`id`: `string`): `Promise`<`void`>

Delete an element from the map.

Use this method to remove elements from the map. This operation cannot be undone.

#### Parameters

| Parameter | Type     | Description                      |
| --------- | -------- | -------------------------------- |
| `id`      | `string` | The id of the element to delete. |

#### Returns

`Promise`<`void`>

A promise that resolves when the element is deleted.

#### Example

```typescript
await felt.deleteElement("element-1");
```

***

### getLayer()

> **getLayer**(`id`: `string`): `Promise`<`null` | [`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)>

Get a single layer from the map by its id.

#### Parameters

| Parameter | Type     | Description                          |
| --------- | -------- | ------------------------------------ |
| `id`      | `string` | The id of the layer you want to get. |

#### Returns

`Promise`<`null` | [`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)>

The requested layer.

#### Example

```typescript
const layer = await felt.getLayer("layer-1");
```

***

### getLayers()

> **getLayers**(`constraint`?: [`GetLayersConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/getlayersconstraint)): `Promise`<(`null` | [`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer))\[]>

Gets layers from the map, according to the constraints supplied. If no constraints are supplied, all layers will be returned.

#### Parameters

| Parameter     | Type                                                                                                 | Description                                                   |
| ------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| `constraint`? | [`GetLayersConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/getlayersconstraint) | The constraints to apply to the layers returned from the map. |

#### Returns

`Promise`<(`null` | [`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer))\[]>

All layers on the map.

#### Remarks

The layers in the map, ordered by the order specified in Felt. This is not necessarily the order that they are drawn in, as Felt draws points above lines and lines above polygons, for instance.

#### Example

```typescript
const layers = await felt.getLayers();
```

***

### setLayerVisibility()

> **setLayerVisibility**(`visibility`: [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest)): `Promise`<`void`>

Hide or show layers with the given ids.

#### Parameters

| Parameter    | Type                                                                                                   |
| ------------ | ------------------------------------------------------------------------------------------------------ |
| `visibility` | [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest) |

#### Returns

`Promise`<`void`>

#### Example

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

***

### setLayerStyle()

> **setLayerStyle**(`params`: { `id`: `string`; `style`: `object`; }): `Promise`<`void`>

Set the style for a layer using FSL, the Felt Style Language.

Changes are only for this session, and not persisted. This is useful to make temporary changes to a layer's style, such as to highlight a particular layer or feature.

See the [FSL documentation](https://developers.felt.com/felt-style-language) for details on how to read and write styles.

If the style you set is invalid, you will receive an error explaining the problem in the rejected promise value.

#### Parameters

| Parameter      | Type                                   | Description                               |
| -------------- | -------------------------------------- | ----------------------------------------- |
| `params`       | { `id`: `string`; `style`: `object`; } | -                                         |
| `params.id`    | `string`                               | The id of the layer to set the style for. |
| `params.style` | `object`                               | The style to set for the layer.           |

#### Returns

`Promise`<`void`>

#### Example

```typescript
// first get the current style
const oldStyle = (await felt.getLayer("layer-1")).style;

await felt.setLayerStyle({ id: "layer-1", style: {
  ...oldStyle,
  paint: {
    ...oldStyle.paint,
    color: "red",
  },
} });
```

***

### setLayerLegendVisibility()

> **setLayerLegendVisibility**(`params`: [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest)): `Promise`<`void`>

Hide or show layers with the given ids from the legend.

#### Parameters

| Parameter | Type                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------ |
| `params`  | [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest) |

#### Returns

`Promise`<`void`>

#### Example

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

***

### createLayersFromGeoJson()

> **createLayersFromGeoJson**(`params`: [`CreateLayersFromGeoJsonParams`](https://developers.felt.com/js-sdk-api-reference/layers/createlayersfromgeojsonparams)): `Promise`<`null` | { `layerGroup`: [`LayerGroup`](https://developers.felt.com/js-sdk-api-reference/layers/layergroup); `layers`: [`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)\[]; }>

Adds layers to the map from file or URL sources.

#### Parameters

| Parameter | Type                                                                                                                     |
| --------- | ------------------------------------------------------------------------------------------------------------------------ |
| `params`  | [`CreateLayersFromGeoJsonParams`](https://developers.felt.com/js-sdk-api-reference/layers/createlayersfromgeojsonparams) |

#### Returns

`Promise`<`null` | { `layerGroup`: [`LayerGroup`](https://developers.felt.com/js-sdk-api-reference/layers/layergroup); `layers`: [`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)\[]; }>

The layer groups that were created.

#### Remarks

This allows you to add temporary layers to the map that don't depend on any processing by Felt. This is useful for viewing data from external sources or remote files.

#### Example

```typescript
const layerFromFile = await felt.createLayersFromGeoJson({
  source: {
    type: "geoJsonFile",
    file: someFile,
  },
  name: "Parcels",
});

const layerFromUrl = await felt.createLayersFromGeoJson({
  source: {
    type: "geoJsonUrl",
    url: "https://example.com/parcels.geojson",
  },
  name: "Parcels",
```

***

### updateLayer()

> **updateLayer**(`params`: [`UpdateLayerParams`](https://developers.felt.com/js-sdk-api-reference/layers/updatelayerparams)): `Promise`<[`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)>

Update a layer by passing a subset of the layer's properties.

Note that not all properties can be updated, so check the [UpdateLayerParams](https://developers.felt.com/js-sdk-api-reference/layers/updatelayerparams) type to see which properties can be updated.

#### Parameters

| Parameter | Type                                                                                             |
| --------- | ------------------------------------------------------------------------------------------------ |
| `params`  | [`UpdateLayerParams`](https://developers.felt.com/js-sdk-api-reference/layers/updatelayerparams) |

#### Returns

`Promise`<[`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)>

#### Example

```typescript
await felt.updateLayer({
  id: "layer-1",
  name: "My Layer",
  caption: "A description of the layer",
});
```

***

### deleteLayer()

> **deleteLayer**(`id`: `string`): `Promise`<`void`>

Delete a layer from the map by its id.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `id`      | `string` |

#### Returns

`Promise`<`void`>

#### Remarks

This only works for layers created via the SDK `createLayersFromGeoJson` method, not layers added via the Felt UI.

#### Example

```typescript
await felt.deleteLayer("layer-1");
```

***

### duplicateLayer()

> **duplicateLayer**(`id`: `string`): `Promise`<[`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)>

Duplicate a layer from the map by its id.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `id`      | `string` |

#### Returns

`Promise`<[`Layer`](https://developers.felt.com/js-sdk-api-reference/layers/layer)>

The duplicated layer.

#### Remarks

This will create an ephemeral copy of the layer, just for the duration of the session. The duplicated layer will not be persisted to the map.

#### Example

```typescript
const duplicatedLayer = await felt.duplicateLayer("layer-1");
```

***

### getLayerGroup()

> **getLayerGroup**(`id`: `string`): `Promise`<`null` | [`LayerGroup`](https://developers.felt.com/js-sdk-api-reference/layers/layergroup)>

Get a layer group from the map by its id.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `id`      | `string` |

#### Returns

`Promise`<`null` | [`LayerGroup`](https://developers.felt.com/js-sdk-api-reference/layers/layergroup)>

The requested layer group.

#### Example

```typescript
const layerGroup = await felt.getLayerGroup("layer-group-1");
```

***

### getLayerGroups()

> **getLayerGroups**(`constraint`?: [`GetLayerGroupsConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/getlayergroupsconstraint)): `Promise`<(`null` | [`LayerGroup`](https://developers.felt.com/js-sdk-api-reference/layers/layergroup))\[]>

Gets layer groups from the map, according to the constraints supplied. If no constraints are supplied, all layer groups will be returned in rendering order.

#### Parameters

| Parameter     | Type                                                                                                           | Description                                                         |
| ------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| `constraint`? | [`GetLayerGroupsConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/getlayergroupsconstraint) | The constraints to apply to the layer groups returned from the map. |

#### Returns

`Promise`<(`null` | [`LayerGroup`](https://developers.felt.com/js-sdk-api-reference/layers/layergroup))\[]>

The requested layer groups.

#### Example

```typescript
const layerGroups = await felt.getLayerGroups({ ids: ["layer-group-1", "layer-group-2"] });
```

***

### setLayerGroupVisibility()

> **setLayerGroupVisibility**(`visibility`: [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest)): `Promise`<`void`>

Hide or show layer groups with the given ids.

#### Parameters

| Parameter    | Type                                                                                                   |
| ------------ | ------------------------------------------------------------------------------------------------------ |
| `visibility` | [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest) |

#### Returns

`Promise`<`void`>

#### Example

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

***

### setLayerGroupLegendVisibility()

> **setLayerGroupLegendVisibility**(`params`: [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest)): `Promise`<`void`>

Hide or show layer groups with the given ids from the legend.

#### Parameters

| Parameter | Type                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------ |
| `params`  | [`SetVisibilityRequest`](https://developers.felt.com/js-sdk-api-reference/shared/setvisibilityrequest) |

#### Returns

`Promise`<`void`>

#### Example

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

***

### getLegendItem()

> **getLegendItem**(`id`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)): `Promise`<`null` | [`LegendItem`](https://developers.felt.com/js-sdk-api-reference/layers/legenditem)>

Allows you to get the state of a single legend item.

#### Parameters

| Parameter | Type                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------ |
| `id`      | [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier) |

#### Returns

`Promise`<`null` | [`LegendItem`](https://developers.felt.com/js-sdk-api-reference/layers/legenditem)>

#### Example

```typescript
const legendItem = await felt.getLegendItem({
  id: "legend-item-1",
  layerId: "layer-1",
})
```

***

### getLegendItems()

> **getLegendItems**(`constraint`?: [`LegendItemsConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemsconstraint)): `Promise`<(`null` | [`LegendItem`](https://developers.felt.com/js-sdk-api-reference/layers/legenditem))\[]>

Allows you to obtain the state of several legend items, by passing in constraints describing which legend items you want.

If you do not pass any constraints, you will receive all legend items.

#### Parameters

| Parameter     | Type                                                                                                     |
| ------------- | -------------------------------------------------------------------------------------------------------- |
| `constraint`? | [`LegendItemsConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemsconstraint) |

#### Returns

`Promise`<(`null` | [`LegendItem`](https://developers.felt.com/js-sdk-api-reference/layers/legenditem))\[]>

#### Example

```typescript
const legendItems = await felt.getLegendItems({layerId: "layer-1"});
```

***

### setLegendItemVisibility()

> **setLegendItemVisibility**(`visibility`: { `show`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)\[]; `hide`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)\[]; }): `Promise`<`void`>

Hide or show legend items with the given identifiers.

#### Parameters

| Parameter          | Type                                                                                                                                                                                                                                      |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `visibility`       | { `show`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)\[]; `hide`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)\[]; } |
| `visibility.show`? | [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)\[]                                                                                                                                 |
| `visibility.hide`? | [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)\[]                                                                                                                                 |

#### Returns

`Promise`<`void`>

#### Example

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

***

### getLayerFilters()

> **getLayerFilters**(`layerId`: `string`): `Promise`<`null` | [`LayerFilters`](https://developers.felt.com/js-sdk-api-reference/layers/layerfilters)>

Get the filters for a layer.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `layerId` | `string` |

#### Returns

`Promise`<`null` | [`LayerFilters`](https://developers.felt.com/js-sdk-api-reference/layers/layerfilters)>

#### Remarks

The return type gives you the filters split up into the various sources that make up the overall filters for a layer.

#### Example

```typescript
const filters = await felt.getLayerFilters("layer-1");
console.log(filters.combined, filters.style, filters.ephemeral, filters.components);
```

***

### setLayerFilters()

> **setLayerFilters**(`params`: { `layerId`: `string`; `filters`: [`Filters`](https://developers.felt.com/js-sdk-api-reference/layers/filters); `note`: `string`; }): `Promise`<`void`>

Sets the **ephemeral** filters for a layer.

#### Parameters

| Parameter        | Type                                                                                                                                | Description                                                                                                                                                          |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params`         | { `layerId`: `string`; `filters`: [`Filters`](https://developers.felt.com/js-sdk-api-reference/layers/filters); `note`: `string`; } | -                                                                                                                                                                    |
| `params.layerId` | `string`                                                                                                                            | The layer that you want to set the filters for.                                                                                                                      |
| `params.filters` | [`Filters`](https://developers.felt.com/js-sdk-api-reference/layers/filters)                                                        | The filters to set for the layer. This will replace any ephemeral filters that are currently set for the layer.                                                      |
| `params.note`?   | `string`                                                                                                                            | A note to display on the layer legend when this filter is applied. When the note is shown, a reset button will also be shown, allowing the user to clear the filter. |

#### Returns

`Promise`<`void`>

#### Example

```typescript
await felt.setLayerFilters({
  layerId: "layer-1",
  filters: ["AREA", "gt", 30_000],
});
```

***

### getLayerBoundaries()

> **getLayerBoundaries**(`layerId`: `string`): `Promise`<`null` | [`LayerBoundaries`](https://developers.felt.com/js-sdk-api-reference/layers/layerboundaries)>

Get the spatial boundaries that are filtering a layer.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `layerId` | `string` |

#### Returns

`Promise`<`null` | [`LayerBoundaries`](https://developers.felt.com/js-sdk-api-reference/layers/layerboundaries)>

#### Remarks

The return type gives you the boundaries split up into the various sources that make up the overall boundary for a layer.

The combined boundary is the intersection of the other sources of boundaries.

#### Example

```typescript
const boundaries = await felt.getLayerBoundaries("layer-1");

console.log(boundaries?.combined);
console.log(boundaries?.spatialFilters);
console.log(boundaries?.ephemeral);
```

***

### setLayerBoundary()

> **setLayerBoundary**(`params`: { `layerIds`: `string`\[]; `boundary`: `null` | [`GeometryFilter`](https://developers.felt.com/js-sdk-api-reference/layers/geometryfilter); }): `Promise`<`void`>

Set the [\`ephemeral\`](https://developers.felt.com/js-sdk-api-reference/layers/layerboundaries#ephemeral) boundary for one or more layers.

#### Parameters

| Parameter         | Type                                                                                                                                           | Description                                                                                    |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `params`          | { `layerIds`: `string`\[]; `boundary`: `null` \| [`GeometryFilter`](https://developers.felt.com/js-sdk-api-reference/layers/geometryfilter); } | -                                                                                              |
| `params.layerIds` | `string`\[]                                                                                                                                    | The ids of the layers to set the boundary for.                                                 |
| `params.boundary` | `null` \| [`GeometryFilter`](https://developers.felt.com/js-sdk-api-reference/layers/geometryfilter)                                           | The boundary to set for the layer. Passing `null` clears the ephemeral boundary for the layer. |

#### Returns

`Promise`<`void`>

#### Example

```typescript
await felt.setLayerBoundary({
  layerIds: ["layer-1", "layer-2"],
  boundary: { type: "MultiPolygon", coordinates: [[[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]]] }
});
```

***

### getRenderedFeatures()

> **getRenderedFeatures**(`params`?: [`GetRenderedFeaturesConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/getrenderedfeaturesconstraint)): `Promise`<[`LayerFeature`](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature)\[]>

Get the features that are currently **rendered** on the map in the viewport.

Note that this is explicitly about the features that are rendered, which isn't necessarily a complete list of all the features in the viewport. This is because of the way features are tiled: at low zoom levels or high feature densities, many features are omitted from what is rendered on the screen.

#### Parameters

| Parameter | Type                                                                                                                     | Description                                                     |
| --------- | ------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
| `params`? | [`GetRenderedFeaturesConstraint`](https://developers.felt.com/js-sdk-api-reference/layers/getrenderedfeaturesconstraint) | The constraints to apply to the features returned from the map. |

#### Returns

`Promise`<[`LayerFeature`](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature)\[]>

#### Example

```typescript
const features = await felt.getRenderedFeatures();
```

***

### getFeature()

> **getFeature**(`params`: { `id`: `string` | `number`; `layerId`: `string`; }): `Promise`<`null` | [`LayerFeature`](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature)>

Get a feature from the map by its ID and layer ID.

The response is a [LayerFeature](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature) object, which does not include the geometry of the feature.

You may want to use this when you don't need the geometry of a feature, but you know the ID of the feature you need.

#### Parameters

| Parameter        | Type                                                 |
| ---------------- | ---------------------------------------------------- |
| `params`         | { `id`: `string` \| `number`; `layerId`: `string`; } |
| `params.id`      | `string` \| `number`                                 |
| `params.layerId` | `string`                                             |

#### Returns

`Promise`<`null` | [`LayerFeature`](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature)>

#### Example

```typescript
const feature = await felt.getFeature({ layerId: "layer-1", id: 123 });
```

***

### getFeatures()

> **getFeatures**(`params`: { `layerId`: `string`; `filters`: [`Filters`](https://developers.felt.com/js-sdk-api-reference/layers/filters); `sorting`: [`SortConfig`](https://developers.felt.com/js-sdk-api-reference/shared/sortconfig); `boundary`: [`GeometryFilter`](https://developers.felt.com/js-sdk-api-reference/layers/geometryfilter); `search`: `string`; `pagination`: `null` | `string`; `pageSize`: `number`; `select`: `string`\[]; }): `Promise`<{ `features`: [`LayerFeature`](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature)\[]; `count`: `number`; `previousPage`: `null` | `string`; `nextPage`: `null` | `string`; }>

Get a list of layer features.

#### Parameters

| Parameter            | Type                                                                                                                                                                                                                                                                                                                                                                                                                        | Description                                                                                                                                                      |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params`             | { `layerId`: `string`; `filters`: [`Filters`](https://developers.felt.com/js-sdk-api-reference/layers/filters); `sorting`: [`SortConfig`](https://developers.felt.com/js-sdk-api-reference/shared/sortconfig); `boundary`: [`GeometryFilter`](https://developers.felt.com/js-sdk-api-reference/layers/geometryfilter); `search`: `string`; `pagination`: `null` \| `string`; `pageSize`: `number`; `select`: `string`\[]; } | -                                                                                                                                                                |
| `params.layerId`     | `string`                                                                                                                                                                                                                                                                                                                                                                                                                    | The ID of the layer to get features from.                                                                                                                        |
| `params.filters`?    | [`Filters`](https://developers.felt.com/js-sdk-api-reference/layers/filters)                                                                                                                                                                                                                                                                                                                                                | Filters to be applied. These filters will merge with layer's own filters.                                                                                        |
| `params.sorting`?    | [`SortConfig`](https://developers.felt.com/js-sdk-api-reference/shared/sortconfig)                                                                                                                                                                                                                                                                                                                                          | Attribute to sort by.                                                                                                                                            |
| `params.boundary`?   | [`GeometryFilter`](https://developers.felt.com/js-sdk-api-reference/layers/geometryfilter)                                                                                                                                                                                                                                                                                                                                  | The spatial boundary to be applied.                                                                                                                              |
| `params.search`?     | `string`                                                                                                                                                                                                                                                                                                                                                                                                                    | Search term to search by. Search is case-insensitive and looks for matches across all feature properties.                                                        |
| `params.pagination`? | `null` \| `string`                                                                                                                                                                                                                                                                                                                                                                                                          | Pagination token. It comes from either the `previousPage` or `nextPage` properties of the previous response.                                                     |
| `params.pageSize`?   | `number`                                                                                                                                                                                                                                                                                                                                                                                                                    | The number of features to return per page. Defaults to 20. Note: The larger the page size, the longer this is likely to take to respond.                         |
| `params.select`?     | `string`\[]                                                                                                                                                                                                                                                                                                                                                                                                                 | The attributes to select from the features. If not provided, all attributes will be returned. If you set this to an empty array, no attributes will be returned. |

#### Returns

`Promise`<{ `features`: [`LayerFeature`](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature)\[]; `count`: `number`; `previousPage`: `null` | `string`; `nextPage`: `null` | `string`; }>

The response is an object which contains:

* `features`: list of [LayerFeature](https://developers.felt.com/js-sdk-api-reference/layers/layerfeature) objects, which does not include the geometry of the feature but it does include its bounding box.
* `count`: the total number of features that match the query.
* `previousPage` & `nextPage`: The tokens to pass in the `pagination` param to navigate between pages.

#### Remarks

This list is paginated in sets of 20 features for each page. In order to paginate between pages, the response includes `previousPage` and `nextPage` that are tokens that should be sent in the `pagination` params for requesting sibling pages.

Text search is case-insensitive and looks for matches across all feature properties.

#### Example

```typescript
const page1Response = await felt.getFeatures({
  layerId: "layer-1",
  search: "abc123",
  pagination: undefined,
});

// Note that the search term here matches the one for the first page.
if (page1Response.nextPage) {
  const page2Response = await felt.getFeatures({
    layerId: "layer-1",
    search: "abc123",
    pagination: page1Response.nextPage,
  });
}
```

***

### getGeoJsonFeature()

> **getGeoJsonFeature**(`params`: { `id`: `string` | `number`; `layerId`: `string`; }): `Promise`<`null` | [`GeoJsonFeature`](https://developers.felt.com/js-sdk-api-reference/shared/geojsonfeature)>

Get a feature in GeoJSON format from the map by its ID and layer ID.

The response is a GeoJSON Feature object with the complete geometry of the feature. Note that for some *very* large geometries, the response may take a long time to return, and may return a very large object.

#### Parameters

| Parameter        | Type                                                 |
| ---------------- | ---------------------------------------------------- |
| `params`         | { `id`: `string` \| `number`; `layerId`: `string`; } |
| `params.id`      | `string` \| `number`                                 |
| `params.layerId` | `string`                                             |

#### Returns

`Promise`<`null` | [`GeoJsonFeature`](https://developers.felt.com/js-sdk-api-reference/shared/geojsonfeature)>

#### Example

```typescript
const feature = await felt.getGeoJsonFeature({ layerId: "layer-1", id: 123 });
```

***

### getCategoryData()

> **getCategoryData**(`params`: [`GetLayerCategoriesParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayercategoriesparams)): `Promise`<[`GetLayerCategoriesGroup`](https://developers.felt.com/js-sdk-api-reference/layers/getlayercategoriesgroup)\[]>

Gets values from a layer grouped by a given attribute.

#### Parameters

| Parameter | Type                                                                                                           |
| --------- | -------------------------------------------------------------------------------------------------------------- |
| `params`  | [`GetLayerCategoriesParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayercategoriesparams) |

#### Returns

`Promise`<[`GetLayerCategoriesGroup`](https://developers.felt.com/js-sdk-api-reference/layers/getlayercategoriesgroup)\[]>

#### Remarks

Groups features in your layer by unique values in the specified attribute and calculates a value for each group. By default, this value is the count of features in each group.

You can apply filters in two ways:

1. At the top level (using `boundary` and `filters`), which affects both what categories are included and how values are calculated
2. In the `values` configuration, which only affects the values but keeps all categories

This two-level filtering is particularly useful when you want to compare subsets of data while maintaining consistent categories. For example, you might want to show the distribution of all building types in a city, but only count buildings built after 2000 in each category.

#### Example

```typescript
// Basic grouping: Count of buildings by type
const buildingsByType = await felt.getCategoryData({
  layerId: "buildings",
  attribute: "type"
});

// Filtered grouping: Only count buildings in downtown
const downtownBuildingsByType = await felt.getCategoryData({
  layerId: "buildings",
  attribute: "type",
  boundary: [-122.43, 47.60, -122.33, 47.62]  // downtown boundary
});

// Advanced: Show all building types, but only sum floor area of recent buildings
const recentBuildingAreaByType = await felt.getCategoryData({
  layerId: "buildings",
  attribute: "type",
  values: {
    filters: ["year_built", "gte", 2000],
    aggregation: {
      method: "sum",
      attribute: "floor_area"
    }
  }
});

// Compare residential density across neighborhoods while only counting recent buildings
const newBuildingDensityByNeighborhood = await felt.getCategoryData({
  layerId: "buildings",
  attribute: "neighborhood",
  values: {
    filters: ["year_built", "gte", 2000],
    aggregation: {
      method: "avg",
      attribute: "units_per_acre"
    }
  }
});
```

***

### getHistogramData()

> **getHistogramData**(`params`: [`GetLayerHistogramParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayerhistogramparams)): `Promise`<[`GetLayerHistogramBin`](https://developers.felt.com/js-sdk-api-reference/layers/getlayerhistogrambin)\[]>

Gets a histogram of values from a layer for a given attribute.

#### Parameters

| Parameter | Type                                                                                                         |
| --------- | ------------------------------------------------------------------------------------------------------------ |
| `params`  | [`GetLayerHistogramParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayerhistogramparams) |

#### Returns

`Promise`<[`GetLayerHistogramBin`](https://developers.felt.com/js-sdk-api-reference/layers/getlayerhistogrambin)\[]>

#### Remarks

Creates bins (ranges) for numeric data and counts how many features fall into each bin, or returns aggregated values for each bin.

You can control how the bins are created using the `steps` parameter, choosing from several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing in the step values directly if you know how you want to bin the data.

Like getCategoryData, you can apply filters in two ways:

1. At the top level (using `boundary` and `filters`), which affects both how the bins are calculated and what features are counted in each bin
2. In the `values` configuration, which only affects what gets counted but keeps the bin ranges the same

This is particularly useful when you want to compare distributions while keeping consistent bin ranges. For example, you might want to compare the distribution of building heights in different years while using the same height ranges.

#### Example

```typescript
// Basic histogram: Building heights in 5 natural break bins
const buildingHeights = await felt.getHistogramData({
  layerId: "buildings",
  attribute: "height",
  steps: { type: "jenks", count: 5 }
});

// Compare old vs new buildings using the same height ranges
const oldBuildingHeights = await felt.getHistogramData({
  layerId: "buildings",
  attribute: "height",
  steps: [0, 20, 50, 100, 200, 500],
  values: {
    filters: ["year_built", "lt", 1950]
  }
});

const newBuildingHeights = await felt.getHistogramData({
  layerId: "buildings",
  attribute: "height",
  steps: [0, 20, 50, 100, 200, 500],  // Same ranges as above
  values: {
    filters: ["year_built", "gte", 1950]
  }
});
```

***

### getAggregates()

> **getAggregates**<`T`>(`params`: [`GetLayerCalculationParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayercalculationparams)<`T`>): `Promise`<`Record`<`T`, `null` | `number`>>

Calculates a single aggregate value for a layer based on the provided configuration.

#### Type Parameters

| Type Parameter                                                                    |
| --------------------------------------------------------------------------------- |
| `T` *extends* `"min"` \| `"max"` \| `"avg"` \| `"sum"` \| `"median"` \| `"count"` |

#### Parameters

| Parameter | Type                                                                                                                  |
| --------- | --------------------------------------------------------------------------------------------------------------------- |
| `params`  | [`GetLayerCalculationParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayercalculationparams)<`T`> |

#### Returns

`Promise`<`Record`<`T`, `null` | `number`>>

#### Remarks

Performs statistical calculations on your data, like counting features or computing averages, sums, etc. You can focus your calculation on specific areas or subsets of your data using boundaries and filters.

When you request an aggregation other than count, you must specify an attribute to aggregate on.

#### Example

```typescript
// Count all residential buildings
const residentialCount = await felt.getAggregates({
  layerId: "buildings",
  filters: ["type", "eq", "residential"],
  aggregation: {
    methods: ["count"],
  }
});

// Calculate average home value in a specific neighborhood
const avgHomeValue = await felt.getAggregates({
  layerId: "buildings",
  boundary: [-122.43, 47.60, -122.33, 47.62],  // neighborhood boundary
  aggregation: {
    methods: ["avg"],
    attribute: "assessed_value"
  }
});

// Find the maximum building height for buildings built after 2000
const maxNewBuildingHeight = await felt.getAggregates({
  layerId: "buildings",
  filters: ["year_built", "gte", 2000],
  aggregation: {
    methods: ["max"],
    attribute: "height"
  }
});
```

***

### getPrecomputedAggregates()

> **getPrecomputedAggregates**(`params`: [`GetLayerPrecomputedCalculationParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayerprecomputedcalculationparams)): `Promise`<{ `avg`: `null` | `number`; `max`: `null` | `number`; `min`: `null` | `number`; `sum`: `null` | `number`; `count`: `null` | `number`; }>

Calculates aggregates for spatial cells of a layer.

#### Parameters

| Parameter | Type                                                                                                                                   |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `params`  | [`GetLayerPrecomputedCalculationParams`](https://developers.felt.com/js-sdk-api-reference/layers/getlayerprecomputedcalculationparams) |

#### Returns

`Promise`<{ `avg`: `null` | `number`; `max`: `null` | `number`; `min`: `null` | `number`; `sum`: `null` | `number`; `count`: `null` | `number`; }>

#### Remarks

Performs statistical calculations on spatial cells of a layer, returning min, max, avg, sum, and count. You can focus your calculation on specific areas or subsets of your data using boundaries and filters. When using the count method, an attribute is not required.

#### Example

```typescript
const aggregates = await felt.getPrecomputedAggregates({
  layerId: "buildings",
  gridConfig: {
    type: "h3",
    resolution: 10,
    method: "avg",
    attribute: "assessed_value"
  },
});
```

***

### getLayerSchema()

> **getLayerSchema**(`layerId`: `string`): `Promise`<[`LayerSchema`](https://developers.felt.com/js-sdk-api-reference/layers/layerschema)>

Get the schema for a layer.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `layerId` | `string` |

#### Returns

`Promise`<[`LayerSchema`](https://developers.felt.com/js-sdk-api-reference/layers/layerschema)>

#### Remarks

The schema describes the structure of the data in a layer, including the attributes that are available on the features in the layer.

This can be useful to build generic UIs that need to know the structure of the data in a layer, such as a dropdown to choose an attribute.

#### Example

```typescript
const schema = await felt.getLayerSchema("layer-1");
const attributeIds = schema.attributes.map((attr) => attr.id);
```

***

### getMapDetails()

> **getMapDetails**(): `Promise`<[`MapDetails`](https://developers.felt.com/js-sdk-api-reference/misc/mapdetails)>

Gets the details of the map.

Use this method to retrieve metadata about the current map, such as its title, description, and other map-level information.

#### Returns

`Promise`<[`MapDetails`](https://developers.felt.com/js-sdk-api-reference/misc/mapdetails)>

A promise that resolves to the map details.

#### Example

```typescript
const details = await felt.getMapDetails();
console.log({
  id: details.id,
  title: details.title,
  description: details.description,
});
```

***

### getSelection()

> **getSelection**(): `Promise`<[`EntityNode`](https://developers.felt.com/js-sdk-api-reference/selection/entitynode)\[]>

Gets the current selection as a list of entity identifiers.

Use this method to retrieve the current selection state, which can include features, elements, or both types of entities.

#### Returns

`Promise`<[`EntityNode`](https://developers.felt.com/js-sdk-api-reference/selection/entitynode)\[]>

A promise that resolves to an array of selected entity nodes.

#### Example

```typescript
const selection = await felt.getSelection();
```

***

### selectFeature()

> **selectFeature**(`params`: [`FeatureSelection`](https://developers.felt.com/js-sdk-api-reference/selection/featureselection)): `Promise`<`void`>

Selects a feature on a layer. This will show the feature's popup, modal or sidebar (if configured) and highlight the feature.

Use this method to programmatically select features, which can be useful for highlighting specific data points or triggering feature-specific UI.

#### Parameters

| Parameter | Type                                                                                              |
| --------- | ------------------------------------------------------------------------------------------------- |
| `params`  | [`FeatureSelection`](https://developers.felt.com/js-sdk-api-reference/selection/featureselection) |

#### Returns

`Promise`<`void`>

A promise that resolves when the feature is selected.

#### Example

```typescript
felt.selectFeature({
  id: 123,
  layerId: "my-layer",
  showPopup: true,
  fitViewport: { maxZoom: 15 },
});
```

***

### clearSelection()

> **clearSelection**(`params`?: { `features`: `boolean`; `elements`: `boolean`; }): `Promise`<`void`>

Clears the current selection (elements, features or both).

Use this method to programmatically clear the current selection, which can be useful for resetting the map state or preparing for new selections.

#### Parameters

| Parameter          | Type                                              | Description                                                                                                 |
| ------------------ | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `params`?          | { `features`: `boolean`; `elements`: `boolean`; } | The parameters to clear the selection. If this is not provided, both features and elements will be cleared. |
| `params.features`? | `boolean`                                         | Whether to clear the features from the selection.                                                           |
| `params.elements`? | `boolean`                                         | Whether to clear the elements from the selection.                                                           |

#### Returns

`Promise`<`void`>

A promise that resolves when the selection is cleared.

#### Example

```typescript

// Removes all features and elements from the selection
felt.clearSelection();

// Removes only features from the selection
felt.clearSelection({ features: true });

// Removes only elements from the selection
felt.clearSelection({ elements: true });
```

#### Default

```typescript
{ features: true, elements: true }
```

***

### setTool()

> **setTool**(`tool`: `null` | [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype)): `void`

Sets the tool to use for drawing elements on the map.

Use this method to programmatically activate drawing tools for users. When a tool is set, users can draw elements on the map using that tool. Set to `null` to deactivate all drawing tools.

#### Parameters

| Parameter | Type                                                                                    | Description                                         |
| --------- | --------------------------------------------------------------------------------------- | --------------------------------------------------- |
| `tool`    | `null` \| [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype) | The tool to set, or `null` to deactivate all tools. |

#### Returns

`void`

#### Example

```typescript
// Set the tool to "marker"
await felt.setTool("marker");

// put down the tool
await felt.setTool(null);
```

***

### getTool()

> **getTool**(): `Promise`<`null` | [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype)>

Gets the current tool, if any is in use.

Use this method to check which drawing tool is currently active, if any.

#### Returns

`Promise`<`null` | [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype)>

A promise that resolves to the current tool, or `null` if no tool is in use.

#### Example

```typescript
const tool = await felt.getTool(); // "marker", "polygon", etc.
```

***

### onToolChange()

> **onToolChange**(`args`: { `handler`: (`tool`: `null` | [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype)) => `void`; }): `VoidFunction`

Listens for changes to the current tool.

Use this to react to tool changes, such as updating your UI to reflect the currently active drawing tool.

#### Parameters

| Parameter      | Type                                                                                                                        | Description                                                              |
| -------------- | --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| `args`         | { `handler`: (`tool`: `null` \| [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype)) => `void`; } | -                                                                        |
| `args.handler` | (`tool`: `null` \| [`ToolType`](https://developers.felt.com/js-sdk-api-reference/tools/tooltype)) => `void`                 | This callback is called with the current tool whenever the tool changes. |

#### Returns

`VoidFunction`

#### Example

```typescript
const unsubscribe = felt.onToolChange({
  handler: tool => console.log(tool),
});

// later on...
unsubscribe();
```

***

### setToolSettings()

> **setToolSettings**(`settings`: [`InputToolSettings`](https://developers.felt.com/js-sdk-api-reference/tools/inputtoolsettings)): `void`

Sets the settings for the current tool.

Use this method to configure how drawing tools behave, such as setting colors, stroke widths, or other tool-specific properties.

#### Parameters

| Parameter  | Type                                                                                            | Description                                 |
| ---------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `settings` | [`InputToolSettings`](https://developers.felt.com/js-sdk-api-reference/tools/inputtoolsettings) | The settings to set for the specified tool. |

#### Returns

`void`

#### Example

```typescript
// Set the settings for the marker tool
await felt.setToolSettings({
  tool: "marker",
  color: "#FE17",
});
```

***

### getToolSettings()

> **getToolSettings**<`T`>(`tool`: `T`): `Promise`<[`ToolSettingsMap`](https://developers.felt.com/js-sdk-api-reference/tools/toolsettingsmap)\[`T`]>

Gets the settings for the chosen tool.

Use this method to retrieve the current configuration of a drawing tool.

#### Type Parameters

| Type Parameter                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------- |
| `T` *extends* [`ConfigurableToolType`](https://developers.felt.com/js-sdk-api-reference/tools/configurabletooltype) |

#### Parameters

| Parameter | Type | Description                   |
| --------- | ---- | ----------------------------- |
| `tool`    | `T`  | The tool to get settings for. |

#### Returns

`Promise`<[`ToolSettingsMap`](https://developers.felt.com/js-sdk-api-reference/tools/toolsettingsmap)\[`T`]>

A promise that resolves to the settings for the chosen tool.

#### Example

```typescript
const settings = await felt.getToolSettings("marker");
```

***

### onToolSettingsChange()

> **onToolSettingsChange**(`args`: { `handler`: (`settings`: [`ToolSettingsChangeEvent`](https://developers.felt.com/js-sdk-api-reference/tools/toolsettingschangeevent)) => `void`; }): `VoidFunction`

Listens for changes to the settings on all tools.

Use this to react to tool setting changes, such as updating your UI to reflect the current tool configuration.

#### Parameters

| Parameter      | Type                                                                                                                                                |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args`         | { `handler`: (`settings`: [`ToolSettingsChangeEvent`](https://developers.felt.com/js-sdk-api-reference/tools/toolsettingschangeevent)) => `void`; } |
| `args.handler` | (`settings`: [`ToolSettingsChangeEvent`](https://developers.felt.com/js-sdk-api-reference/tools/toolsettingschangeevent)) => `void`                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onToolSettingsChange({
  handler: settings => console.log(settings),
});

// later on...
unsubscribe();
```

***

### createActionTrigger()

> **createActionTrigger**(`args`: [`CreateActionTriggerParams`](https://developers.felt.com/js-sdk-api-reference/ui/createactiontriggerparams)): `Promise`<[`UIActionTriggerCreate`](https://developers.felt.com/js-sdk-api-reference/ui/uiactiontriggercreate)>

Creates an action trigger. Action triggers are rendered on map's left sidebar as a button, similar to other map extensions like measure and spatial filter.

The goal of action triggers is to allow users to perform actions on the map by clicking on a button.

#### Parameters

| Parameter | Type                                                                                                         | Description                   |
| --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- |
| `args`    | [`CreateActionTriggerParams`](https://developers.felt.com/js-sdk-api-reference/ui/createactiontriggerparams) | The arguments for the method. |

#### Returns

`Promise`<[`UIActionTriggerCreate`](https://developers.felt.com/js-sdk-api-reference/ui/uiactiontriggercreate)>

#### Example

```typescript
await felt.createActionTrigger({
  actionTrigger: {
    id: "enablePolygonTool", // optional. Required if you want to update the action trigger later
    label: "Draw polygon",
    onTrigger: async () => {
      felt.setTool("polygon");
    },
    disabled: false, // optional, defaults to false
  },
  placement: { at: "start" }, // optional, defaults to { at: "end" }
});
```

***

### updateActionTrigger()

> **updateActionTrigger**(`args`: [`UpdateActionTriggerParams`](https://developers.felt.com/js-sdk-api-reference/ui/updateactiontriggerparams)): `Promise`<[`UIActionTriggerCreate`](https://developers.felt.com/js-sdk-api-reference/ui/uiactiontriggercreate)>

Updates an action trigger.

Action trigger to update is identified by the `id` property.

#### Parameters

| Parameter | Type                                                                                                         | Description                   |
| --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- |
| `args`    | [`UpdateActionTriggerParams`](https://developers.felt.com/js-sdk-api-reference/ui/updateactiontriggerparams) | The action trigger to update. |

#### Returns

`Promise`<[`UIActionTriggerCreate`](https://developers.felt.com/js-sdk-api-reference/ui/uiactiontriggercreate)>

#### Remarks

Properties provided will override the existing properties.

#### Example

```typescript
await felt.updateActionTrigger({
  id: "enablePolygonTool",
  label: "Enable polygon tool", // only label changes
});
```

***

### deleteActionTrigger()

> **deleteActionTrigger**(`id`: `string`): `void`

Deletes an action trigger.

#### Parameters

| Parameter | Type     | Description                             |
| --------- | -------- | --------------------------------------- |
| `id`      | `string` | The id of the action trigger to delete. |

#### Returns

`void`

#### Example

```typescript
await felt.deleteActionTrigger("enablePolygonTool");
```

***

### createFeatureAction()

> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](https://developers.felt.com/js-sdk-api-reference/ui/createfeatureactionparams)): `Promise`<[`UIFeatureAction`](https://developers.felt.com/js-sdk-api-reference/ui/uifeatureaction)>

Creates a feature contextual action.

#### Parameters

| Parameter | Type                                                                                                         | Description                   |
| --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- |
| `args`    | [`CreateFeatureActionParams`](https://developers.felt.com/js-sdk-api-reference/ui/createfeatureactionparams) | The arguments for the method. |

#### Returns

`Promise`<[`UIFeatureAction`](https://developers.felt.com/js-sdk-api-reference/ui/uifeatureaction)>

#### Example

```typescript
const myAction = await felt.createFeatureAction({
  action: {
    label: "Add to selection",
    onTrigger: async ({ feature }) => {
      console.log(`Adding feature ${feature.id} from layer ${feature.layerId} to selection`);
    },
    layerIds: ["layer-1", "layer-2"], // Display the feature action only on these layers
  },
  placement: { at: "start" }, // optional, defaults to { at: "end" }
});

```

***

### updateFeatureAction()

> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](https://developers.felt.com/js-sdk-api-reference/ui/updatefeatureactionparams)): `Promise`<[`UIFeatureAction`](https://developers.felt.com/js-sdk-api-reference/ui/uifeatureaction)>

Updates a feature contextual action.

Feature contextual action to update is identified by the `id` property.

#### Parameters

| Parameter | Type                                                                                                         | Description                              |
| --------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------- |
| `args`    | [`UpdateFeatureActionParams`](https://developers.felt.com/js-sdk-api-reference/ui/updatefeatureactionparams) | The feature contextual action to update. |

#### Returns

`Promise`<[`UIFeatureAction`](https://developers.felt.com/js-sdk-api-reference/ui/uifeatureaction)>

#### Remarks

Properties provided will override the existing properties.

#### Example

```typescript
const myAction = await felt.createFeatureAction({ ... });
await felt.updateFeatureAction({
  id: myAction.id,
  label: "Updated action label", // only label changes
});
```

***

### deleteFeatureAction()

> **deleteFeatureAction**(`id`: `string`): `void`

Deletes a feature contextual action.

#### Parameters

| Parameter | Type     | Description                                        |
| --------- | -------- | -------------------------------------------------- |
| `id`      | `string` | The id of the feature contextual action to delete. |

#### Returns

`void`

#### Example

```typescript
const myAction = await felt.createFeatureAction({ ... });
await felt.deleteFeatureAction(myAction.id);
```

***

### createPanelId()

> **createPanelId**(): `Promise`<`string`>

Creates a panel ID.

In order to create a panel using [createOrUpdatePanel](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller#createorupdatepanel), you need to create a panel ID first. Panel IDs are automatically generated to prevent conflicts with other panels.

#### Returns

`Promise`<`string`>

#### Example

```typescript
const panelId = await felt.createPanelId();
```

***

### createOrUpdatePanel()

> **createOrUpdatePanel**(`args`: [`CreateOrUpdatePanelParams`](https://developers.felt.com/js-sdk-api-reference/ui/createorupdatepanelparams)): `Promise`<[`UIPanel`](https://developers.felt.com/js-sdk-api-reference/ui/uipanel)>

Creates or updates a panel.

Panels are rendered on the map's right sidebar and allow you to extend Felt UI for your own use cases using Felt UI elements (e.g., Text, Button, etc.).

A panel is identified by its ID, which must be created using [createPanelId](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller#createpanelid). Custom IDs are not supported to prevent conflicts with other panels.

Panels have two main sections:

* `body` - The main content area of the panel, which is scrollable.
* `footer` - A section that sticks to the bottom of the panel, useful for action buttons like "Submit" or "Cancel".

Panel placement is controlled by the `initialPlacement` parameter. By default, panels are added to the end of the panel stack, but you can specify a different placement. Note that this placement cannot be changed after the panel is created.

Element IDs are required for targeted updates and deletions using the other panel management methods. For complete panel refreshes with this method, element IDs are optional but recommended for consistency.

For dynamic content management, consider these approaches:

* Use this method for complete panel refreshes (replaces all content)
* Use [createPanelElements](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller#createpanelelements) to add new elements to existing panels
* Use [updatePanelElements](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller#updatepanelelements) to modify specific existing elements
* Use [deletePanelElements](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller#deletepanelelements) to remove specific elements

#### Parameters

| Parameter | Type                                                                                                         | Description                                       |
| --------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------- |
| `args`    | [`CreateOrUpdatePanelParams`](https://developers.felt.com/js-sdk-api-reference/ui/createorupdatepanelparams) | The arguments for creating or updating the panel. |

#### Returns

`Promise`<[`UIPanel`](https://developers.felt.com/js-sdk-api-reference/ui/uipanel)>

#### Example

```typescript
// 1. Create panel ID first (required)
const panelId = await felt.createPanelId();

// 2. Define reusable elements
const SELECT = { id: "layer-select", type: "Select", label: "Layer", options: [...] };
const ANALYZE_BTN = { id: "analyze-btn", type: "Button", label: "Analyze", onClick: handleAnalyze };
const STATUS_TEXT = { id: "status-text", type: "Text", content: "" };
const CLEAR_BTN = { id: "clear-btn", type: "Button", label: "Clear", onClick: handleClear };

// 3. Initial state
await felt.createOrUpdatePanel({
  panel: { id: panelId, title: "Data Analyzer", body: [SELECT, ANALYZE_BTN] }
});

// 4. Loading state (replaces entire panel)
await felt.createOrUpdatePanel({
  panel: {
    id: panelId,
    title: "Data Analyzer",
    body: [SELECT, ANALYZE_BTN, { ...STATUS_TEXT, content: "Loading..." }]
  }
});

// 5. Results state (replaces entire panel)
await felt.createOrUpdatePanel({
  panel: {
    id: panelId,
    title: "Data Analyzer",
    body: [SELECT, ANALYZE_BTN, { ...STATUS_TEXT, content: "**Results:**\n- Found 150 features" }, CLEAR_BTN]
  }
});
```

***

### deletePanel()

> **deletePanel**(`id`: `string`): `void`

Deletes a panel.

#### Parameters

| Parameter | Type     | Description                    |
| --------- | -------- | ------------------------------ |
| `id`      | `string` | The id of the panel to delete. |

#### Returns

`void`

#### Example

```typescript
await felt.deletePanel("panel-1");
```

***

### createPanelElements()

> **createPanelElements**(`args`: [`CreatePanelElementsParams`](https://developers.felt.com/js-sdk-api-reference/ui/createpanelelementsparams)): `Promise`<[`UIPanel`](https://developers.felt.com/js-sdk-api-reference/ui/uipanel)>

Creates elements in a panel.

Use this method to add new elements to an existing panel without replacing the entire panel content. This is useful for dynamic UI updates.

#### Parameters

| Parameter | Type                                                                                                         | Description                   |
| --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- |
| `args`    | [`CreatePanelElementsParams`](https://developers.felt.com/js-sdk-api-reference/ui/createpanelelementsparams) | The arguments for the method. |

#### Returns

`Promise`<[`UIPanel`](https://developers.felt.com/js-sdk-api-reference/ui/uipanel)>

#### Example

```typescript
await felt.createPanelElements({
  panelId,
  elements: [
    {
      element: { type: "Text", content: "Hello, world!" },
      container: "body",
      placement: { at: "start" },
    },
  ],
});
```

***

### updatePanelElements()

> **updatePanelElements**(`args`: [`UpdatePanelElementsParams`](https://developers.felt.com/js-sdk-api-reference/ui/updatepanelelementsparams)): `Promise`<[`UIPanel`](https://developers.felt.com/js-sdk-api-reference/ui/uipanel)>

Updates an existing element in a panel. This method can only update elements that already exist in the panel and have an ID.

Use this method to modify specific elements without replacing the entire panel. This is more efficient than using [createOrUpdatePanel](https://developers.felt.com/js-sdk-api-reference/ui/uicontroller#createorupdatepanel) for small changes.

#### Parameters

| Parameter | Type                                                                                                         | Description                   |
| --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- |
| `args`    | [`UpdatePanelElementsParams`](https://developers.felt.com/js-sdk-api-reference/ui/updatepanelelementsparams) | The arguments for the method. |

#### Returns

`Promise`<[`UIPanel`](https://developers.felt.com/js-sdk-api-reference/ui/uipanel)>

#### Example

```typescript
// 1. Create panel with initial elements
const panelId = await felt.createPanelId();
const STATUS_TEXT = { id: "status-text", type: "Text", content: "Ready" };

await felt.createOrUpdatePanel({
  panel: {
    id: panelId,
    title: "My Panel",
    body: [STATUS_TEXT]
  }
});

// 2. Update the existing element
await felt.updatePanelElements({
  panelId,
  elements: [
    {
      element: {
        ...STATUS_TEXT,                    // Reuse the same element structure
        content: "Updated content"         // Only change what needs updating
      },
    },
  ],
});
```

***

### deletePanelElements()

> **deletePanelElements**(`args`: [`DeletePanelElementsParams`](https://developers.felt.com/js-sdk-api-reference/ui/deletepanelelementsparams)): `void`

Deletes elements from a panel.

Use this method to remove specific elements from a panel without replacing the entire panel content.

#### Parameters

| Parameter | Type                                                                                                         | Description                   |
| --------- | ------------------------------------------------------------------------------------------------------------ | ----------------------------- |
| `args`    | [`DeletePanelElementsParams`](https://developers.felt.com/js-sdk-api-reference/ui/deletepanelelementsparams) | The arguments for the method. |

#### Returns

`void`

#### Example

```typescript
await felt.deletePanelElements({
  panelId,
  elements: ["element-1", "element-2"],
});
```

***

### updateUiControls()

> **updateUiControls**(`controls`: [`UiControlsOptions`](https://developers.felt.com/js-sdk-api-reference/ui/uicontrolsoptions)): `void`

Updates the UI controls on the embedded map.

Use this method to show or hide various UI controls like the legend, full screen button, and other map interface elements.

#### Parameters

| Parameter  | Type                                                                                         | Description             |
| ---------- | -------------------------------------------------------------------------------------------- | ----------------------- |
| `controls` | [`UiControlsOptions`](https://developers.felt.com/js-sdk-api-reference/ui/uicontrolsoptions) | The controls to update. |

#### Returns

`void`

#### Example

```typescript
// Show some UI controls
await felt.updateUiControls({
  showLegend: true,
  fullScreenButton: true,
});

// Disable some UI options
await felt.updateUiControls({
  cooperativeGestures: false,
  geolocation: false,
});
```

***

### setOnMapInteractionsUi()

> **setOnMapInteractionsUi**(`options`: [`OnMapInteractionsOptions`](https://developers.felt.com/js-sdk-api-reference/ui/onmapinteractionsoptions)): `void`

Control the on-map UI shown when interacting with features and elements.

If you add your own click, selection or hover handlers you may want to disable various parts of the Felt UI. This method allows you to control the visibility of various parts of the UI that might otherwise be shown when people click or hover on things.

This does not affect selection. That means that selectable features and elements will still be selected when clicked.

#### Parameters

| Parameter | Type                                                                                                       |
| --------- | ---------------------------------------------------------------------------------------------------------- |
| `options` | [`OnMapInteractionsOptions`](https://developers.felt.com/js-sdk-api-reference/ui/onmapinteractionsoptions) |

#### Returns

`void`

#### Example

```typescript
// Disable UI when hovering or selecting features
await felt.setOnMapInteractionsUi({
  featureSelectPanel: false,
  featureHoverPanel: false,
});
```

***

### showLayerDataTable()

> **showLayerDataTable**(`params`?: { `layerId`: `string`; `sorting`: [`SortConfig`](https://developers.felt.com/js-sdk-api-reference/shared/sortconfig); }): `Promise`<`void`>

Shows a data table view for the specified layer, optionally sorted by a given attribute.

The data table displays feature data in a tabular format, making it easy to browse and analyze layer data. You can control the initial sorting of the table.

#### Parameters

| Parameter         | Type                                                                                                                    | Description                                     |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| `params`?         | { `layerId`: `string`; `sorting`: [`SortConfig`](https://developers.felt.com/js-sdk-api-reference/shared/sortconfig); } | Optional parameters for showing the data table. |
| `params.layerId`? | `string`                                                                                                                | The ID of the layer to show data for.           |
| `params.sorting`? | [`SortConfig`](https://developers.felt.com/js-sdk-api-reference/shared/sortconfig)                                      | Optional sorting configuration for the table.   |

#### Returns

`Promise`<`void`>

#### Example

```typescript
// Show data table with default sorting
await felt.showLayerDataTable({
  layerId: "layer-1",
});

// Show data table sorted by height in descending order
await felt.showLayerDataTable({
  layerId: "layer-1",
  sorting: {
    attribute: "height",
    direction: "desc",
  },
});

// Show the data table pane with no table visible
await felt.showLayerDataTable();
```

***

### hideLayerDataTable()

> **hideLayerDataTable**(): `Promise`<`void`>

Hides the data table.

#### Returns

`Promise`<`void`>

#### Example

```typescript
await felt.hideLayerDataTable();
```

***

### getViewport()

> **getViewport**(): `Promise`<[`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)>

Gets the current state of the viewport.

Use this method to retrieve the current center coordinates and zoom level of the map viewport.

#### Returns

`Promise`<[`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)>

A promise that resolves to the current viewport state.

#### Example

```typescript
// Get current viewport state
const viewport = await felt.getViewport();
console.log({
  center: viewport.center,
  zoom: viewport.zoom,
});
```

***

### setViewport()

> **setViewport**(`viewport`: [`SetViewportCenterZoomParams`](https://developers.felt.com/js-sdk-api-reference/viewport/setviewportcenterzoomparams)): `void`

Moves the map to the specified location.

Use this method to programmatically change the map's viewport to a specific location and zoom level. The map will animate to the new position.

#### Parameters

| Parameter  | Type                                                                                                                   |
| ---------- | ---------------------------------------------------------------------------------------------------------------------- |
| `viewport` | [`SetViewportCenterZoomParams`](https://developers.felt.com/js-sdk-api-reference/viewport/setviewportcenterzoomparams) |

#### Returns

`void`

#### Example

```typescript
felt.setViewport({
  center: { latitude: 0, longitude: 0 },
  zoom: 10,
});
```

***

### getViewportConstraints()

> **getViewportConstraints**(): `Promise`<`null` | [`ViewportConstraints`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportconstraints)>

Gets the current state of the viewport constraints.

Use this method to retrieve the current viewport constraints, which limit where users can pan and zoom on the map.

#### Returns

`Promise`<`null` | [`ViewportConstraints`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportconstraints)>

A promise that resolves to the current viewport constraints, or `null` if no constraints are set.

#### Example

```typescript
// Get current viewport constraints
const constraints = await felt.getViewportConstraints();
if (constraints) {
  console.log({
    bounds: constraints.bounds,
    minZoom: constraints.minZoom,
    maxZoom: constraints.maxZoom
  });
} else {
  console.log("No viewport constraints set");
}
```

***

### setViewportConstraints()

> **setViewportConstraints**(`constraints`: `null` | `Partial`<[`ViewportConstraints`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportconstraints)>): `void`

Constrains the map viewport so it stays inside certain bounds and/or certain zoom levels.

Use this method to limit where users can navigate on the map. This is useful for keeping users focused on a specific area or preventing them from zooming too far in or out.

#### Parameters

| Parameter     | Type                                                                                                                        |
| ------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `constraints` | `null` \| `Partial`<[`ViewportConstraints`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportconstraints)> |

#### Returns

`void`

#### Examples

```typescript
felt.setViewportConstraints({
  bounds: [-122.5372532, 37.6652478, -122.1927016, 37.881707],
  minZoom: 1,
  maxZoom: 23,
});
```

every constraint is optional

```typescript
felt.setViewportConstraints({
  bounds: [-122.5372532, 37.6652478, -122.1927016, 37.881707],
});
```

if a constraint is null, it will be removed but keeping the others

```typescript
felt.setViewportConstraints({ bounds: null });
```

if method receives null, it will remove the constraints

```typescript
felt.setViewportConstraints(null);
```

***

### fitViewportToBounds()

> **fitViewportToBounds**(`bounds`: [`ViewportFitBoundsParams`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportfitboundsparams)): `void`

Fits the map to the specified bounds.

Use this method to automatically adjust the viewport to show a specific geographic area. The map will calculate the appropriate center and zoom level to fit the bounds within the current map size.

#### Parameters

| Parameter | Type                                                                                                           |
| --------- | -------------------------------------------------------------------------------------------------------------- |
| `bounds`  | [`ViewportFitBoundsParams`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportfitboundsparams) |

#### Returns

`void`

#### Example

```typescript
const west = -122.4194;
const south = 37.7749;
const east = -122.4194;
const north = 37.7749;
felt.fitViewportToBounds({ bounds: [west, south, east, north] });
```

## Events

### onBasemapChange()

> **onBasemapChange**(`args`: { `handler`: (`basemap`: [`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)) => `void`; }): `VoidFunction`

Adds a listener for when the basemap changes.

Use this to react to basemap changes, such as updating your UI or adjusting other map elements to match the new basemap's color scheme.

#### Parameters

| Parameter      | Type                                                                                                                  |
| -------------- | --------------------------------------------------------------------------------------------------------------------- |
| `args`         | { `handler`: (`basemap`: [`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)) => `void`; } |
| `args.handler` | (`basemap`: [`Basemap`](https://developers.felt.com/js-sdk-api-reference/basemaps/basemap)) => `void`                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
// Listen for basemap changes
const unsubscribe = felt.onBasemapChange({
  handler: basemap => {
    console.log(`Switched to ${basemap.name}`);
    updateUIColors(basemap.uiColorScheme);
  },
});

// later on...
unsubscribe();
```

***

### onElementCreate()

> **onElementCreate**(`args`: { `handler`: (`change`: [`ElementChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams)) => `void`; }): `VoidFunction`

Adds a listener for when an element is created.

This will fire when elements are created programmatically, or when the user starts creating an element with a drawing tool.

When the user creates an element with a drawing tool, it can begin in an invalid state, such as if you've just placed a single point in a polygon.

You can use the `isBeingCreated` property to determine if the element is still being created by a drawing tool.

If you want to know when the element is finished being created, you can use the [\`onElementCreateEnd\`](https://developers.felt.com/js-sdk-api-reference/elements/elementscontroller#onelementcreateend) listener.

#### Parameters

| Parameter      | Type                                                                                                                                                         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args`         | { `handler`: (`change`: [`ElementChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams)) => `void`; } | -                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `args.handler` | (`change`: [`ElementChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams)) => `void`                 | The handler that is called when an element is created. This will fire when elements are created programmatically, or when the user starts creating an element with a drawing tool. When the user creates an element with a drawing tool, it can begin in an invalid state, such as if you've just placed a single point in a polygon. You can use the `isBeingCreated` property to determine if the element is still being created by a drawing tool. If you want to know when the element is finished being created, you can use the [\`onElementCreateEnd\`](https://developers.felt.com/js-sdk-api-reference/elements/elementscontroller#onelementcreateend) listener. |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onElementCreate({
  handler: ({isBeingCreated, element}) => console.log(element.id),
});

// later on...
unsubscribe();
```

***

### onElementCreateEnd()

> **onElementCreateEnd**(`args`: { `handler`: (`params`: { `element`: [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element); }) => `void`; }): `VoidFunction`

Listens for when a new element is finished being created by a drawing tool.

This differs from the [\`onElementCreate\`](https://developers.felt.com/js-sdk-api-reference/elements/elementscontroller#onelementcreate) listener, which fires whenever an element is first created. This fires when the user finishes creating an element which could be after a series of interactions.

For example, when creating a polygon, the user places a series of points then finishes by pressing Enter or Escape. Or when creating a Place element, they add the marker, type a label, then finally deselect the element.

#### Parameters

| Parameter      | Type                                                                                                                                 | Description                                    |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- |
| `args`         | { `handler`: (`params`: { `element`: [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element); }) => `void`; } | -                                              |
| `args.handler` | (`params`: { `element`: [`Element`](https://developers.felt.com/js-sdk-api-reference/elements/element); }) => `void`                 | The handler to call whenever this event fires. |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onElementCreateEnd({
  handler: (params) => console.log(params),
});

// later on...
unsubscribe();
```

***

### onElementChange()

> **onElementChange**(`args`: { `options`: { `id`: `string`; }; `handler`: (`change`: [`ElementChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams)) => `void`; }): `VoidFunction`

Adds a listener for when an element changes.

This will fire when an element is being edited, either on the map by the user or programmatically.

Like the [\`onElementCreate\`](https://developers.felt.com/js-sdk-api-reference/elements/elementscontroller#onelementcreate) listener, this will fire when an element is still being created by a drawing tool.

You can check the [\`isBeingCreated\`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams#isbeingcreated) property to determine if the element is still being created by a drawing tool.

#### Parameters

| Parameter         | Type                                                                                                                                                                                         | Description                                          |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `args`            | { `options`: { `id`: `string`; }; `handler`: (`change`: [`ElementChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams)) => `void`; } | -                                                    |
| `args.options`    | { `id`: `string`; }                                                                                                                                                                          | -                                                    |
| `args.options.id` | `string`                                                                                                                                                                                     | The id of the element to listen for changes to.      |
| `args.handler`    | (`change`: [`ElementChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementchangecallbackparams)) => `void`                                                 | The handler that is called when the element changes. |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onElementChange({
  options: { id: "element-1" },
  handler: ({element}) => console.log(element.id),
});

// later on...
unsubscribe();
```

***

### onElementDelete()

> **onElementDelete**(`args`: { `options`: { `id`: `string`; }; `handler`: () => `void`; }): `VoidFunction`

Adds a listener for when an element is deleted.

Use this to react to element deletions, such as cleaning up related data or updating your application state.

#### Parameters

| Parameter         | Type                                                         | Description                                             |
| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------- |
| `args`            | { `options`: { `id`: `string`; }; `handler`: () => `void`; } | -                                                       |
| `args.options`    | { `id`: `string`; }                                          | -                                                       |
| `args.options.id` | `string`                                                     | The id of the element to listen for deletions of.       |
| `args.handler`    | () => `void`                                                 | The handler that is called when the element is deleted. |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onElementDelete({
  options: { id: "element-1" },
  handler: () => console.log("element-1 deleted"),
});

// later on...
unsubscribe();
```

***

### onElementGroupChange()

> **onElementGroupChange**(`args`: { `options`: { `id`: `string`; }; `handler`: (`change`: [`ElementGroupChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroupchangecallbackparams)) => `void`; }): `VoidFunction`

Adds a listener for when an element group changes.

Use this to react to changes in element groups, such as when elements are added to or removed from groups.

#### Parameters

| Parameter         | Type                                                                                                                                                                                                   |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `args`            | { `options`: { `id`: `string`; }; `handler`: (`change`: [`ElementGroupChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroupchangecallbackparams)) => `void`; } |
| `args.options`    | { `id`: `string`; }                                                                                                                                                                                    |
| `args.options.id` | `string`                                                                                                                                                                                               |
| `args.handler`    | (`change`: [`ElementGroupChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/elements/elementgroupchangecallbackparams)) => `void`                                                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onElementGroupChange({
  options: { id: "element-group-1" },
  handler: elementGroup => console.log(elementGroup.id),
});

// later on...
unsubscribe();
```

***

### onPointerClick()

> **onPointerClick**(`params`: { `handler`: (`event`: [`MapInteractionEvent`](https://developers.felt.com/js-sdk-api-reference/interactions/mapinteractionevent)) => `void`; }): `VoidFunction`

Allows you to be notified when the user clicks on the map.

Use this to react to user clicks on the map, such as triggering custom actions or collecting interaction data.

#### Parameters

| Parameter        | Type                                                                                                                                            |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `params`         | { `handler`: (`event`: [`MapInteractionEvent`](https://developers.felt.com/js-sdk-api-reference/interactions/mapinteractionevent)) => `void`; } |
| `params.handler` | (`event`: [`MapInteractionEvent`](https://developers.felt.com/js-sdk-api-reference/interactions/mapinteractionevent)) => `void`                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onPointerClick({
  handler: (event) => console.log(event.center, event.features),
});

// later on...
unsubscribe();
```

***

### onPointerMove()

> **onPointerMove**(`params`: { `handler`: (`event`: [`MapInteractionEvent`](https://developers.felt.com/js-sdk-api-reference/interactions/mapinteractionevent)) => `void`; }): `VoidFunction`

Allows you to be notified when the user moves the mouse over the map.

Use this to track mouse movement and detect features under the cursor, such as for hover effects or real-time data display.

#### Parameters

| Parameter        | Type                                                                                                                                            | Description             |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |
| `params`         | { `handler`: (`event`: [`MapInteractionEvent`](https://developers.felt.com/js-sdk-api-reference/interactions/mapinteractionevent)) => `void`; } | Params for the listener |
| `params.handler` | (`event`: [`MapInteractionEvent`](https://developers.felt.com/js-sdk-api-reference/interactions/mapinteractionevent)) => `void`                 | The handler function    |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
// Track mouse movement and features under cursor
const unsubscribe = felt.onPointerMove({
  handler: (event) => {
    console.log("Mouse position:", event.center);
    console.log("Features under cursor:", event.features);
  }
});

// later on...
unsubscribe();
```

***

### onLayerChange()

> **onLayerChange**(`args`: { `options`: { `id`: `string`; }; `handler`: (`change`: [`LayerChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/layerchangecallbackparams)) => `void`; }): `VoidFunction`

Adds a listener for when a layer changes.

#### Parameters

| Parameter         | Type                                                                                                                                                                                   | Description                                        |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `args`            | { `options`: { `id`: `string`; }; `handler`: (`change`: [`LayerChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/layerchangecallbackparams)) => `void`; } | -                                                  |
| `args.options`    | { `id`: `string`; }                                                                                                                                                                    | -                                                  |
| `args.options.id` | `string`                                                                                                                                                                               | The id of the layer to listen for changes to.      |
| `args.handler`    | (`change`: [`LayerChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/layerchangecallbackparams)) => `void`                                                 | The handler that is called when the layer changes. |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener

#### Example

```typescript
const unsubscribe = felt.onLayerChange({
  options: { id: "layer-1" },
  handler: ({layer}) => console.log(layer.bounds),
});

// later on...
unsubscribe();
```

***

### onLayerGroupChange()

> **onLayerGroupChange**(`args`: { `options`: { `id`: `string`; }; `handler`: (`change`: [`LayerGroupChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/layergroupchangecallbackparams)) => `void`; }): `VoidFunction`

Adds a listener for when a layer group changes.

#### Parameters

| Parameter         | Type                                                                                                                                                                                             |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `args`            | { `options`: { `id`: `string`; }; `handler`: (`change`: [`LayerGroupChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/layergroupchangecallbackparams)) => `void`; } |
| `args.options`    | { `id`: `string`; }                                                                                                                                                                              |
| `args.options.id` | `string`                                                                                                                                                                                         |
| `args.handler`    | (`change`: [`LayerGroupChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/layergroupchangecallbackparams)) => `void`                                                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener

#### Example

```typescript
const unsubscribe = felt.onLayerGroupChange({
  options: { id: "layer-group-1" },
  handler: ({layerGroup}) => console.log(layerGroup.id),
});

// later on...
unsubscribe();
```

***

### onLegendItemChange()

> **onLegendItemChange**(`args`: { `options`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier); `handler`: (`change`: [`LegendItemChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemchangecallbackparams)) => `void`; }): `VoidFunction`

Adds a listener for when a legend item changes.

#### Parameters

| Parameter      | Type                                                                                                                                                                                                                                                                                |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `args`         | { `options`: [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier); `handler`: (`change`: [`LegendItemChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemchangecallbackparams)) => `void`; } |
| `args.options` | [`LegendItemIdentifier`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemidentifier)                                                                                                                                                                              |
| `args.handler` | (`change`: [`LegendItemChangeCallbackParams`](https://developers.felt.com/js-sdk-api-reference/layers/legenditemchangecallbackparams)) => `void`                                                                                                                                    |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener

#### Example

```typescript
const unsubscribe = felt.onLegendItemChange({
  options: { layerId: "layer-1", id: "item-1-0" },
  handler: ({legendItem}) => console.log(legendItem.visible),
});

// later on...
unsubscribe();
```

***

### onLayerFiltersChange()

> **onLayerFiltersChange**(`params`: { `options`: { `layerId`: `string`; }; `handler`: (`change`: [`LayerFilters`](https://developers.felt.com/js-sdk-api-reference/layers/layerfilters)) => `void`; }): `VoidFunction`

Adds a listener for when a layer's filters change.

#### Parameters

| Parameter                | Type                                                                                                                                                              |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `params`                 | { `options`: { `layerId`: `string`; }; `handler`: (`change`: [`LayerFilters`](https://developers.felt.com/js-sdk-api-reference/layers/layerfilters)) => `void`; } |
| `params.options`         | { `layerId`: `string`; }                                                                                                                                          |
| `params.options.layerId` | `string`                                                                                                                                                          |
| `params.handler`         | (`change`: [`LayerFilters`](https://developers.felt.com/js-sdk-api-reference/layers/layerfilters)) => `void`                                                      |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener

#### Remarks

This event fires whenever any type of filter changes on the layer, including ephemeral filters set via the SDK, style-based filters, or filters set through the Felt UI via Components.

#### Example

```typescript
const unsubscribe = felt.onLayerFiltersChange({
  options: { layerId: "layer-1" },
  handler: ({combined, ephemeral, style, components}) => {
    console.log("Layer filters updated:", {
      combined,  // All filters combined
      ephemeral, // Filters set via SDK
      style,     // Filters from layer style
      components // Filters from UI components
    });
  },
});

// later on...
unsubscribe();
```

***

### onLayerBoundariesChange()

> **onLayerBoundariesChange**(`params`: { `options`: { `layerId`: `string`; }; `handler`: (`boundaries`: `null` | [`LayerBoundaries`](https://developers.felt.com/js-sdk-api-reference/layers/layerboundaries)) => `void`; }): `VoidFunction`

Adds a listener for when a layer's spatial boundaries change.

#### Parameters

| Parameter                | Type                                                                                                                                                                                  | Description                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| `params`                 | { `options`: { `layerId`: `string`; }; `handler`: (`boundaries`: `null` \| [`LayerBoundaries`](https://developers.felt.com/js-sdk-api-reference/layers/layerboundaries)) => `void`; } | -                                                      |
| `params.options`         | { `layerId`: `string`; }                                                                                                                                                              | -                                                      |
| `params.options.layerId` | `string`                                                                                                                                                                              | The id of the layer to listen for boundary changes on. |
| `params.handler`         | (`boundaries`: `null` \| [`LayerBoundaries`](https://developers.felt.com/js-sdk-api-reference/layers/layerboundaries)) => `void`                                                      | A function that is called when the boundaries change.  |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener

#### Remarks

This event fires whenever any type of spatial boundary changes on the layer, including ephemeral boundaries set via the SDK or boundaries set through the Felt UI via Spatial filter components.

#### Example

```typescript
const unsubscribe = felt.onLayerBoundariesChange({
  options: { layerId: "layer-1" },
  handler: ({combined, ephemeral, spatialFilters}) => {
    console.log("Layer boundaries updated:", {
      combined,  // All boundaries combined
      ephemeral, // Boundaries set via SDK
      spatialFilters // Boundaries set via UI
    });
  },
});

// later on...
unsubscribe();
```

***

### onSelectionChange()

> **onSelectionChange**(`params`: { `handler`: (`change`: { `selection`: [`EntityNode`](https://developers.felt.com/js-sdk-api-reference/selection/entitynode)\[]; }) => `void`; }): `VoidFunction`

Adds a listener for when the selection changes.

Use this to react to selection changes, such as updating your UI to reflect what is currently selected on the map.

#### Parameters

| Parameter        | Type                                                                                                                                             |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `params`         | { `handler`: (`change`: { `selection`: [`EntityNode`](https://developers.felt.com/js-sdk-api-reference/selection/entitynode)\[]; }) => `void`; } |
| `params.handler` | (`change`: { `selection`: [`EntityNode`](https://developers.felt.com/js-sdk-api-reference/selection/entitynode)\[]; }) => `void`                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onSelectionChange({
  handler: ({selection}) => console.log(selection),
});

// later on...
unsubscribe();
```

***

### onViewportMove()

> **onViewportMove**(`args`: { `handler`: (`viewport`: [`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)) => `void`; }): `VoidFunction`

Adds a listener for when the viewport changes.

Use this to react to viewport changes, such as updating your UI or triggering other actions when users navigate the map.

#### Parameters

| Parameter      | Type                                                                                                                               | Description                                                                            |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `args`         | { `handler`: (`viewport`: [`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)) => `void`; } | -                                                                                      |
| `args.handler` | (`viewport`: [`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)) => `void`                 | This callback is called with the current viewport state whenever the viewport changes. |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onViewportMove({
  handler: viewport => console.log(viewport.center.latitude),
});

// later on...
unsubscribe();
```

***

### onViewportMoveEnd()

> **onViewportMoveEnd**(`args`: { `handler`: (`viewport`: [`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)) => `void`; }): `VoidFunction`

Adds a listener for when the viewport move ends, which is when the user stops dragging or zooming the map, animations have finished, or inertial dragging ends.

Use this to react to the end of viewport changes, such as triggering data loading or analysis when users finish navigating.

#### Parameters

| Parameter      | Type                                                                                                                               |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `args`         | { `handler`: (`viewport`: [`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)) => `void`; } |
| `args.handler` | (`viewport`: [`ViewportState`](https://developers.felt.com/js-sdk-api-reference/viewport/viewportstate)) => `void`                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onViewportMoveEnd({
  handler: viewport => console.log(viewport.center.latitude),
});

// later on...
unsubscribe();
```

***

### onMapIdle()

> **onMapIdle**(`args`: { `handler`: () => `void`; }): `VoidFunction`

Adds a listener for when the map is idle, which is defined as:

* No transitions are in progress
* The user is not interacting with the map, e.g. by panning or zooming
* All tiles for the current viewport have been loaded
* Any fade transitions (e.g. for labels) have completed

Use this to perform actions when the map is completely stable and ready for user interaction, such as enabling certain features or triggering data analysis.

#### Parameters

| Parameter      | Type                         |
| -------------- | ---------------------------- |
| `args`         | { `handler`: () => `void`; } |
| `args.handler` | () => `void`                 |

#### Returns

`VoidFunction`

A function to unsubscribe from the listener.

#### Example

```typescript
const unsubscribe = felt.onMapIdle({ handler: () => console.log("map is idle") });

// later on...
unsubscribe();
```

## Properties

### iframe

> `readonly` **iframe**: `null` | `HTMLIFrameElement`

The iframe element containing the Felt map, if it is an embedded map.
