The Felt SDK provides functionality for reading the current selection state and selecting features on the map programmatically. This is useful for building interactive experiences that respond to data analysis or user interactions.
Selecting Features
Features are individual data points within layers. You can select features programmatically using the selectFeature() method. Only one feature can be selected at a time - selecting a new feature will replace the current selection.
The selectFeature() method accepts options to control the selection behavior:
awaitfelt.selectFeature({id:"feature-123",layerId:"buildings-layer",showPopup:false,// Whether to show the feature popup (default: true)fitViewport:{maxZoom:15}// Fit viewport to feature with zoom limit});
showPopup (boolean, default: true) - Whether to display the feature information popup
fitViewport (boolean | { maxZoom: number }, default: true) - Whether to fit the viewport to the feature. Can be true, false, or an object with maxZoom to limit the zoom level used.
Reading selection
You can get the current selection state using getSelection(). This returns an array of EntityNode objects, each representing a selected entity. The selection can include various types of entities at the same time, such as annotations and features: