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.
ViewportController
.UiController
.LayersController
.ElementsController
.SelectionController
.InteractionsController
.ToolsController
.MiscController
readonly
iframe:null
|HTMLIFrameElement
The iframe element containing the Felt map, if it is an embedded map.
getElement(
id
:string
):Promise
<null
|Element
>
Get a single element from the map by its id.
Parameter | Type | Description |
---|---|---|
id |
string |
The id of the element you want to get. |
Promise
<null
| Element
>
The requested element.
const element = await felt.getElement("element-1");
getElementGeometry(
id
:string
):Promise
<null
|Geometry
>
Get the geometry of an element.
Parameter | Type | Description |
---|---|---|
id |
string |
The id of the element you want to get the geometry of. |
Promise
<null
| Geometry
>
const geometry = await felt.getElementGeometry("element-1");
console.log(geometry?.type, geometry?.coordinates);
getElements(
constraint
?:GetElementsConstraint
):Promise
<(null
|Element
)[]>
Gets elements from the map, according to the constraints supplied. If no constraints are supplied, all elements will be returned.
Parameter | Type | Description |
---|---|---|
constraint ? |
GetElementsConstraint |
The constraints to apply to the elements returned from the map. |
Promise
<(null
| Element
)[]>
All elements on the map.
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.
const elements = await felt.getElements();
getElementGroup(
id
:string
):Promise
<null
|ElementGroup
>
Get an element group from the map by its id.
Parameter | Type |
---|---|
id |
string |
Promise
<null
| ElementGroup
>
The requested element group.
const elementGroup = await felt.getElementGroup("element-group-1");
getElementGroups(
constraint
?:GetElementGroupsConstraint
):Promise
<(null
|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.
Parameter | Type | Description |
---|---|---|
constraint ? |
GetElementGroupsConstraint |
The constraints to apply to the element groups returned from the map. |
Promise
<(null
| ElementGroup
)[]>
The requested element groups.
const elementGroups = await felt.getElementGroups({ ids: ["element-group-1", "element-group-2"] });
setElementGroupVisibility(
visibility
:SetVisibilityRequest
):Promise
<void
>
Hide or show element groups with the given ids.
Parameter | Type |
---|---|
visibility |
SetVisibilityRequest |
Promise
<void
>
felt.setElementGroupVisibility({ show: ["element-group-1", "element-group-2"], hide: ["element-group-3"] });
createElement(
element
:ElementCreate
):Promise
<Element
>
Create a new element on the map.
Parameter | Type |
---|---|
element |
ElementCreate |
Promise
<Element
>
const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
updateElement(
element
:ElementUpdate
):Promise
<Element
>
Update an element on the map.
Parameter | Type |
---|---|
element |
ElementUpdate |
Promise
<Element
>
deleteElement(
id
:string
):Promise
<void
>
Delete an element from the map.
Parameter | Type |
---|---|
id |
string |
Promise
<void
>
getLayer(
id
:string
):Promise
<null
|Layer
>
Get a single layer from the map by its id.
Parameter | Type | Description |
---|---|---|
id |
string |
The id of the layer you want to get. |
Promise
<null
| Layer
>
The requested layer.
const layer = await felt.getLayer("layer-1");
getLayers(
constraint
?:GetLayersConstraint
):Promise
<(null
|Layer
)[]>
Gets layers from the map, according to the constraints supplied. If no constraints are supplied, all layers will be returned.
Parameter | Type | Description |
---|---|---|
constraint ? |
GetLayersConstraint |
The constraints to apply to the layers returned from the map. |
Promise
<(null
| Layer
)[]>
All layers on the map.
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.
const layers = await felt.getLayers();
setLayerVisibility(
visibility
:SetVisibilityRequest
):Promise
<void
>
Hide or show layers with the given ids.
Parameter | Type |
---|---|
visibility |
SetVisibilityRequest |
Promise
<void
>
felt.setLayerVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
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 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.
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. |
Promise
<void
>
// first get the current style
const oldStyle = (await felt.getLayer("layer-1")).style;
felt.setLayerStyle({ id: "layer-1", style: {
...oldStyle,
paint: {
...oldStyle.paint,
color: "red",
},
} });
setLayerLegendVisibility(
params
:SetVisibilityRequest
):Promise
<void
>
Hide or show layers with the given ids from the legend.
Parameter | Type |
---|---|
params |
SetVisibilityRequest |
Promise
<void
>
felt.setLayerLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
getLayerGroup(
id
:string
):Promise
<null
|LayerGroup
>
Get a layer group from the map by its id.
Parameter | Type |
---|---|
id |
string |
Promise
<null
| LayerGroup
>
The requested layer group.
const layerGroup = await felt.getLayerGroup("layer-group-1");
getLayerGroups(
constraint
?:GetLayerGroupsConstraint
):Promise
<(null
|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.
Parameter | Type | Description |
---|---|---|
constraint ? |
GetLayerGroupsConstraint |
The constraints to apply to the layer groups returned from the map. |
Promise
<(null
| LayerGroup
)[]>
The requested layer groups.
const layerGroups = await felt.getLayerGroups({ ids: ["layer-group-1", "layer-group-2"] });
setLayerGroupVisibility(
visibility
:SetVisibilityRequest
):Promise
<void
>
Hide or show layer groups with the given ids.
Parameter | Type |
---|---|
visibility |
SetVisibilityRequest |
Promise
<void
>
felt.setLayerGroupVisibility({ show: ["layer-group-1", "layer-group-2"], hide: ["layer-group-3"] });
setLayerGroupLegendVisibility(
params
:SetVisibilityRequest
):Promise
<void
>
Hide or show layer groups with the given ids from the legend.
Parameter | Type |
---|---|
params |
SetVisibilityRequest |
Promise
<void
>
felt.setLayerGroupLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
getLegendItem(
id
:LegendItemIdentifier
):Promise
<null
|LegendItem
>
Allows you to get the state of a single legend item.
Parameter | Type |
---|---|
id |
LegendItemIdentifier |
Promise
<null
| LegendItem
>
const legendItem = await felt.getLegendItem({
id: "legend-item-1",
layerId: "layer-1",
})
getLegendItems(
constraint
?:LegendItemsConstraint
):Promise
<(null
|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.
Parameter | Type |
---|---|
constraint ? |
LegendItemsConstraint |
Promise
<(null
| LegendItem
)[]>
const legendItems = await felt.getLegendItems({layerId: "layer-1"});
setLegendItemVisibility(
visibility
: {show
:LegendItemIdentifier
[];hide
:LegendItemIdentifier
[]; }):Promise
<void
>
Hide or show legend items with the given identifiers.
Parameter | Type |
---|---|
visibility |
{ show : LegendItemIdentifier []; hide : LegendItemIdentifier []; } |
visibility.show ? |
LegendItemIdentifier [] |
visibility.hide ? |
LegendItemIdentifier [] |
Promise
<void
>
felt.setLegendItemVisibility({
show: [{layerId: "layer-group-1", id: "item-1-0"}],
hide: [{layerId: "layer-group-2", id: "item-2-0"}],
})
getLayerFilters(
layerId
:string
):Promise
<null
|LayerFilters
>
Get the filters for a layer.
Parameter | Type |
---|---|
layerId |
string |
Promise
<null
| LayerFilters
>
The return type gives you the filters split up into the various sources that make up the overall filters for a layer.
const filters = await felt.getLayerFilters("layer-1");
console.log(filters.combined, filters.style, filters.ephemeral, filters.components);
setLayerFilters(
params
: {layerId
:string
;filters
:Filters
;note
:string
; }):Promise
<void
>
Sets the ephemeral filters for a layer.
Parameter | Type | Description |
---|---|---|
params |
{ layerId : string ; filters : Filters ; note : string ; } |
- |
params.layerId |
string |
The layer that you want to set the filters for. |
params.filters |
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. |
Promise
<void
>
felt.setLayerFilters({
layerId: "layer-1",
filters: ["AREA", "gt", 30_000],
});
getRenderedFeatures(
params
?:GetRenderedFeaturesConstraint
):Promise
<Feature
[]>
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.
Parameter | Type | Description |
---|---|---|
params ? |
GetRenderedFeaturesConstraint |
The constraints to apply to the features returned from the map. |
Promise
<Feature
[]>
const features = await felt.getRenderedFeatures();
getCategoryData(
params
:GetLayerCategoriesParams
):Promise
<GetLayerCategoriesGroup
[]>
Gets values from a layer grouped by a given attribute.
Parameter | Type |
---|---|
params |
GetLayerCategoriesParams |
Promise
<GetLayerCategoriesGroup
[]>
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:
- At the top level (using
boundary
andfilters
), which affects both what categories are included and how values are calculated - 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.
// 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(
params
:GetLayerHistogramParams
):Promise
<GetLayerHistogramBin
[]>
Gets a histogram of values from a layer for a given attribute.
Parameter | Type |
---|---|
params |
GetLayerHistogramParams |
Promise
<GetLayerHistogramBin
[]>
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:
- At the top level (using
boundary
andfilters
), which affects both how the bins are calculated and what features are counted in each bin - 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.
// 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<
T
>(params
:GetLayerCalculationParams
<T
>):Promise
<Record
<T
,null
|number
>>
Calculates a single aggregate value for a layer based on the provided configuration.
Type Parameter |
---|
T extends "avg" | "max" | "min" | "sum" | "median" | "count" |
Parameter | Type |
---|---|
params |
GetLayerCalculationParams <T > |
Promise
<Record
<T
, null
| number
>>
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 no aggregation is specified, it counts features. When an aggregation is provided, it performs that calculation (average, sum, etc.) on the specified attribute.
// Count all residential buildings
const residentialCount = await felt.getAggregates({
layerId: "buildings",
filters: ["type", "eq", "residential"]
});
// 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: {
method: "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: {
method: "max",
attribute: "height"
}
});
getMapDetails():
Promise
<MapDetails
>
Gets the details of the map.
Promise
<MapDetails
>
getSelection():
Promise
<EntityNode
[]>
Gets the current selection as a list of entity identifiers.
Promise
<EntityNode
[]>
const selection = await felt.getSelection();
selectFeature(
params
: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.
Parameter | Type |
---|---|
params |
FeatureSelection |
Promise
<void
>
felt.selectFeature({
id: 123,
layerId: "my-layer",
showPopup: true,
fitViewport: { maxZoom: 15 },
});
clearSelection(
params
?: {features
:boolean
;elements
:boolean
; }):Promise
<void
>
Clears the current selection. This clears the selection of
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. |
Promise
<void
>
// 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 });
{ features: true, elements: true }
setTool(
tool
:null
|"text"
|"note"
|"pin"
|"line"
|"route"
|"polygon"
|"circle"
|"marker"
|"highlighter"
|"link"
):void
Sets the tool to use for drawing elements on the map.
Parameter | Type | Description |
---|---|---|
tool |
null | "text" | "note" | "pin" | "line" | "route" | "polygon" | "circle" | "marker" | "highlighter" | "link" |
The tool to set. |
void
// Set the tool to "marker"
felt.setTool("marker");
// put down the tool
felt.setTool(null);
getTool():
Promise
<null
|"text"
|"note"
|"pin"
|"line"
|"route"
|"polygon"
|"circle"
|"marker"
|"highlighter"
|"link"
>
Gets the current tool, if any is in use.
Promise
<null
| "text"
| "note"
| "pin"
| "line"
| "route"
| "polygon"
| "circle"
| "marker"
| "highlighter"
| "link"
>
The current tool, or null
if no tool is in use.
const tool = await felt.getTool(); // "marker", "polygon", etc.
onToolChange(
args
: {handler
: (tool
:null
|"text"
|"note"
|"pin"
|"line"
|"route"
|"polygon"
|"circle"
|"marker"
|"highlighter"
|"link"
) =>void
; }):VoidFunction
Listens for changes to the current tool.
Parameter | Type | Description |
---|---|---|
args |
{ handler : (tool : null | "text" | "note" | "pin" | "line" | "route" | "polygon" | "circle" | "marker" | "highlighter" | "link" ) => void ; } |
- |
args.handler |
(tool : null | "text" | "note" | "pin" | "line" | "route" | "polygon" | "circle" | "marker" | "highlighter" | "link" ) => void |
This callback is called with the current tool whenever the tool changes. |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onToolChange({
handler: tool => console.log(tool),
});
// later on...
unsubscribe();
setToolSettings(
settings
:InputToolSettings
):void
Sets the settings for the current tool.
Parameter | Type | Description |
---|---|---|
settings |
InputToolSettings |
The settings to set. |
void
getToolSettings<
T
>(tool
:T
):Promise
<ToolSettingsMap
[T
]>
Gets the settings for the current tool.
Type Parameter |
---|
T extends keyof ToolSettingsMap |
Parameter | Type |
---|---|
tool |
T |
Promise
<ToolSettingsMap
[T
]>
The settings for the current tool.
onToolSettingsChange(
args
: {handler
: (settings
:ToolSettingsChangeEvent
) =>void
; }):VoidFunction
Listens for changes to the settings on all tools.
Parameter | Type |
---|---|
args |
{ handler : (settings : ToolSettingsChangeEvent ) => void ; } |
args.handler |
(settings : ToolSettingsChangeEvent ) => void |
VoidFunction
A function to unsubscribe from the listener
updateUiControls(
controls
:UiControlsOptions
):void
Updates the UI controls on the embedded map.
Parameter | Type | Description |
---|---|---|
controls |
UiControlsOptions |
The controls to update. |
void
setOnMapInteractionsUi(
options
: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.
Parameter | Type |
---|---|
options |
OnMapInteractionsOptions |
void
getViewport():
Promise
<ViewportState
>
Gets the current state of the viewport.
Promise
<ViewportState
>
setViewport(
viewport
:SetViewportCenterZoomParams
):void
Moves the map to the specified location.
Parameter | Type |
---|---|
viewport |
SetViewportCenterZoomParams |
void
felt.setViewport({
center: { latitude: 0, longitude: 0 },
zoom: 10,
});
getViewportConstraints():
Promise
<null
|ViewportConstraints
>
Gets the current state of the viewport constraints.
Promise
<null
| ViewportConstraints
>
setViewportConstraints(
constraints
:null
|Partial
<ViewportConstraints
>):void
Constrains the map viewport so it stays inside certain bounds and/or certain zoom levels.
Parameter | Type |
---|---|
constraints |
null | Partial <ViewportConstraints > |
void
felt.setViewportConstraints({
bounds: [-122.5372532, 37.6652478, -122.1927016, 37.881707],
minZoom: 1,
maxZoom: 23,
});
every constraint is optional
felt.setViewportConstraints({
bounds: [-122.5372532, 37.6652478, -122.1927016, 37.881707],
});
if a constraint is null, it will be removed but keeping the others
felt.setViewportConstraints({ bounds: null });
if method receives null, it will remove the constraints
felt.setViewportConstraints(null);
fitViewportToBounds(
bounds
:ViewportFitBoundsParams
):void
Fits the map to the specified bounds.
Parameter | Type |
---|---|
bounds |
ViewportFitBoundsParams |
void
const west = -122.4194;
const south = 37.7749;
const east = -122.4194;
const north = 37.7749;
felt.fitViewportToBounds({ bounds: [west, south, east, north] });
onElementCreate(
args
: {handler
: (change
:ElementChangeCallbackParams
) =>void
; }):VoidFunction
Adds a listener for when an element is created.
Parameter | Type | Description |
---|---|---|
args |
{ handler : (change : ElementChangeCallbackParams ) => void ; } |
- |
args.handler |
(change : ElementChangeCallbackParams ) => void |
The handler that is called when an element is created. |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onElementCreate({
handler: (element) => console.log(element.id),
});
// later on...
unsubscribe();
onElementChange(
args
: {options
: {id
:string
; };handler
: (change
:ElementChangeCallbackParams
) =>void
; }):VoidFunction
Adds a listener for when an element changes.
Parameter | Type | Description |
---|---|---|
args |
{ options : { id : string ; }; handler : (change : ElementChangeCallbackParams ) => void ; } |
- |
args.options |
{ id : string ; } |
- |
args.options.id |
string |
The id of the element to listen for changes to. |
args.handler |
(change : ElementChangeCallbackParams ) => void |
The handler that is called when the element changes. |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onElementChange({
options: { id: "element-1" },
handler: ({element}) => console.log(element.id),
});
// later on...
unsubscribe();
onElementDelete(
args
: {options
: {id
:string
; };handler
: () =>void
; }):VoidFunction
Adds a listener for when an element is deleted.
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. |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onElementDelete({
options: { id: "element-1" },
handler: (element) => console.log(element.id),
});
// later on...
unsubscribe();
onElementGroupChange(
args
: {options
: {id
:string
; };handler
: (change
:ElementGroupChangeCallbackParams
) =>void
; }):VoidFunction
Adds a listener for when an element group changes.
Parameter | Type |
---|---|
args |
{ options : { id : string ; }; handler : (change : ElementGroupChangeCallbackParams ) => void ; } |
args.options |
{ id : string ; } |
args.options.id |
string |
args.handler |
(change : ElementGroupChangeCallbackParams ) => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onElementGroupChange({
options: { id: "element-group-1" },
handler: elementGroup => console.log(elementGroup.id),
});
// later on...
unsubscribe();
onPointerClick(
params
: {handler
: (event
:MapInteractionEvent
) =>void
; }):VoidFunction
Allows you to be notified the user clicks on the map.
Parameter | Type |
---|---|
params |
{ handler : (event : MapInteractionEvent ) => void ; } |
params.handler |
(event : MapInteractionEvent ) => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onPointerClick({
handler: (event) => console.log(event.center, event.features),
});
// later on...
unsubscribe();
onPointerMove(
params
: {handler
: (event
:MapInteractionEvent
) =>void
; }):VoidFunction
Allows you to be notified the user moves the mouse over the map.
Parameter | Type | Description |
---|---|---|
params |
{ handler : (event : MapInteractionEvent ) => void ; } |
Params for the listener |
params.handler |
(event : MapInteractionEvent ) => void |
The handler function |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onPointerMove({
handler: (event) => console.log(event.center, event.features),
});
// later on...
unsubscribe();
onLayerChange(
args
: {options
: {id
:string
; };handler
: (change
:LayerChangeCallbackParams
) =>void
; }):VoidFunction
Adds a listener for when a layer changes.
Parameter | Type | Description |
---|---|---|
args |
{ options : { id : string ; }; handler : (change : LayerChangeCallbackParams ) => void ; } |
- |
args.options |
{ id : string ; } |
- |
args.options.id |
string |
The id of the layer to listen for changes to. |
args.handler |
(change : LayerChangeCallbackParams ) => void |
The handler that is called when the layer changes. |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onLayerChange({
options: { id: "layer-1" },
handler: ({layer}) => console.log(layer.bounds),
});
// later on...
unsubscribe();
onLayerGroupChange(
args
: {options
: {id
:string
; };handler
: (change
:LayerGroupChangeCallbackParams
) =>void
; }):VoidFunction
Adds a listener for when a layer group changes.
Parameter | Type |
---|---|
args |
{ options : { id : string ; }; handler : (change : LayerGroupChangeCallbackParams ) => void ; } |
args.options |
{ id : string ; } |
args.options.id |
string |
args.handler |
(change : LayerGroupChangeCallbackParams ) => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onLayerGroupChange({
options: { id: "layer-group-1" },
handler: ({layerGroup}) => console.log(layerGroup.id),
});
// later on...
unsubscribe();
onLegendItemChange(
args
: {options
:LegendItemIdentifier
;handler
: (change
:LegendItemChangeCallbackParams
) =>void
; }):VoidFunction
Adds a listener for when a legend item changes.
Parameter | Type |
---|---|
args |
{ options : LegendItemIdentifier ; handler : (change : LegendItemChangeCallbackParams ) => void ; } |
args.options |
LegendItemIdentifier |
args.handler |
(change : LegendItemChangeCallbackParams ) => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onLegendItemChange({
options: { layerId: "layer-1", id: "item-1-0" },
handler: ({legendItem}) => console.log(legendItem.visible),
});
// later on...
unsubscribe();
onSelectionChange(
params
: {handler
: (change
: {selection
:EntityNode
[]; }) =>void
; }):VoidFunction
Adds a listener for when the selection changes.
Parameter | Type |
---|---|
params |
{ handler : (change : { selection : EntityNode []; }) => void ; } |
params.handler |
(change : { selection : EntityNode []; }) => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onSelectionChange({
handler: ({selection}) => console.log(selection),
});
// later on...
unsubscribe();
onViewportMove(
args
: {handler
: (viewport
:ViewportState
) =>void
; }):VoidFunction
Adds a listener for when the viewport changes.
Parameter | Type | Description |
---|---|---|
args |
{ handler : (viewport : ViewportState ) => void ; } |
- |
args.handler |
(viewport : ViewportState ) => void |
This callback is called with the current viewport state whenever the viewport changes. |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onViewportMove({
handler: viewport => console.log(viewport.center.latitude),
});
// later on...
unsubscribe();
onViewportMoveEnd(
args
: {handler
: (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.
Parameter | Type |
---|---|
args |
{ handler : (viewport : ViewportState ) => void ; } |
args.handler |
(viewport : ViewportState ) => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onViewportMoveEnd({
handler: viewport => console.log(viewport.center.latitude),
});
// later on...
unsubscribe();
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
Parameter | Type |
---|---|
args |
{ handler : () => void ; } |
args.handler |
() => void |
VoidFunction
A function to unsubscribe from the listener
const unsubscribe = felt.onMapIdle({ handler: () => console.log("map is idle") });
// later on...
unsubscribe();