@feltmaps/js-sdk 1.5.0-next.2 → 1.5.0-next.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, L as Layer, f as GetLayersConstraint, g as LayerChangeCallbackParams, h as LayerGroup, i as GetLayerGroupsConstraint, j as LayerGroupChangeCallbackParams, k as LegendItemIdentifier, l as LegendItem, m as LegendItemsConstraint, n as LegendItemChangeCallbackParams, o as LayerFilters, F as Filters, p as GetRenderedFeaturesConstraint, q as Feature, M as MapInteractionEvent, r as EntityNode, s as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, t as ToolSettingsMap, u as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, v as SetViewportCenterZoomParams, w as ViewportConstraints, x as ViewportFitBoundsParams, y as ViewportCenterZoom } from './types-BLsf5GHN.js';
2
- export { a1 as CircleToolSettings, J as ElementGroupNode, K as ElementNode, N as FeatureNode, Q as FeltBoundary, U as FeltZoom, B as FilterExpression, D as FilterLogicGate, H as FilterTernary, a2 as HighlighterToolSettings, W as LatLng, O as LayerGroupNode, P as LayerNode, A as LayerProcessingStatus, X as LineStringGeometry, a3 as LineToolSettings, Y as LngLatTuple, a4 as MarkerToolSettings, Z as MultiLineStringGeometry, _ as MultiPolygonGeometry, a5 as NoteToolSettings, a6 as PinFrame, a7 as PinSymbol, a8 as PinToolSettings, $ as PointGeometry, a0 as PolygonGeometry, a9 as PolygonToolSettings, R as RasterValue, aa as RouteToolSettings, ab as TextToolSettings } from './types-BLsf5GHN.js';
1
+ import { E as Element, G as GeoJsonGeometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, C as CreateLayersFromGeoJsonParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as LayerFeature, t as GeoJsonFeature, u as GetLayerCategoriesParams, v as GetLayerCategoriesGroup, w as GetLayerHistogramParams, x as GetLayerHistogramBin, A as AggregationMethod, y as GetLayerCalculationParams, z as LayerSchema, M as MapInteractionEvent, B as MapDetails, D as EntityNode, H as FeatureSelection, T as ToolType, I as InputToolSettings, J as ConfigurableToolType, K as ToolSettingsMap, N as ToolSettingsChangeEvent, O as zInfer, P as SortConfig, V as ViewportState, Q as SetViewportCenterZoomParams, R as ViewportConstraints, U as ViewportFitBoundsParams, W as ViewportCenterZoom } from './types-f_Zc32jS.js';
2
+ export { aJ as AggregationConfig, X as CircleElementCreate, Y as CircleElementRead, Z as CircleElementUpdate, b2 as CircleToolSettings, an as DataOnlyLayer, aN as ElementGroupNode, aO as ElementNode, aP as FeatureNode, aS as FeltBoundary, ao as FeltTiledVectorSource, aT as FeltZoom, aG as FilterExpression, aH as FilterLogicGate, aI as FilterTernary, ap as GeoJsonDataVectorSource, aq as GeoJsonFileVectorSource, aU as GeoJsonProperties, ar as GeoJsonUrlVectorSource, aK as GeometryFilter, _ as HighlighterElementCreate, $ as HighlighterElementRead, a0 as HighlighterElementUpdate, b3 as HighlighterToolSettings, a1 as ImageElementCreate, a2 as ImageElementRead, a3 as ImageElementUpdate, aV as LatLng, as as LayerCommon, aQ as LayerGroupNode, aR as LayerNode, at as LayerProcessingStatus, az as LayerSchemaAttribute, aA as LayerSchemaBooleanAttribute, aB as LayerSchemaCommonAttribute, aC as LayerSchemaDateAttribute, aD as LayerSchemaDateTimeAttribute, aE as LayerSchemaNumericAttribute, aF as LayerSchemaTextAttribute, aW as LineStringGeometry, b4 as LineToolSettings, a4 as LinkElementRead, aX as LngLatTuple, a5 as MarkerElementCreate, a6 as MarkerElementRead, a7 as MarkerElementUpdate, b5 as MarkerToolSettings, aL as MultiAggregationConfig, aY as MultiLineStringGeometry, aZ as MultiPointGeometry, a_ as MultiPolygonGeometry, a8 as NoteElementCreate, a9 as NoteElementRead, aa as NoteElementUpdate, b6 as NoteToolSettings, ab as PathElementCreate, ac as PathElementRead, ad as PathElementUpdate, b7 as PinToolSettings, ae as PlaceElementCreate, af as PlaceElementRead, ag as PlaceElementUpdate, b8 as PlaceFrame, b9 as PlaceSymbol, a$ as PointGeometry, ah as PolygonElementCreate, ai as PolygonElementRead, aj as PolygonElementUpdate, b0 as PolygonGeometry, ba as PolygonToolSettings, au as RasterBand, av as RasterLayer, aw as RasterLayerSource, ax as RasterValue, bb as RouteToolSettings, b1 as SortDirection, ak as TextElementCreate, al as TextElementRead, am as TextElementUpdate, bc as TextToolSettings, aM as ValueConfiguration, ay as VectorLayer } from './types-f_Zc32jS.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -25,7 +25,23 @@ interface ElementsController {
25
25
  */
26
26
  id: string): Promise<Element | null>;
27
27
  /**
28
- * Get the geometry of an element.
28
+ * Get the geometry of an element in GeoJSON geometry format.
29
+ *
30
+ * For most element types, the geometry returned is based on the `coordinates`
31
+ * property of the element, with some differences:
32
+ *
33
+ * - For Circle elements, the geometry is a Polygon drawn from the `center` and
34
+ * `radius` properties.
35
+ *
36
+ * - Path elements become MultiLineString geometries.
37
+ *
38
+ * - Marker elements return a MultiLineString of the path traced by the user
39
+ * as they drew the marker. Note that this is not the polygon formed by filled-in
40
+ * "pen" stroke, which doesn't exactly follow the path traced by the user as it
41
+ * is smoothed and interpolated to create a continuous line.
42
+ *
43
+ * - Text, Note and Image elements do not return geometry, so will return `null`.
44
+ *
29
45
  *
30
46
  * @example
31
47
  * ```typescript
@@ -37,7 +53,7 @@ interface ElementsController {
37
53
  /**
38
54
  * The id of the element you want to get the geometry of.
39
55
  */
40
- id: string): Promise<Geometry | null>;
56
+ id: string): Promise<GeoJsonGeometry | null>;
41
57
  /**
42
58
  * Gets elements from the map, according to the constraints supplied. If no
43
59
  * constraints are supplied, all elements will be returned.
@@ -62,7 +78,7 @@ interface ElementsController {
62
78
  *
63
79
  * @example
64
80
  * ```typescript
65
- * felt.getElementGroup("element-group-1");
81
+ * const elementGroup = await felt.getElementGroup("element-group-1");
66
82
  * ```
67
83
  * @returns The requested element group.
68
84
  */
@@ -91,9 +107,88 @@ interface ElementsController {
91
107
  * ```
92
108
  */
93
109
  setElementGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
110
+ /**
111
+ * Adds a listener for when an element is created.
112
+ *
113
+ * @returns A function to unsubscribe from the listener
114
+ *
115
+ * @event
116
+ * @example
117
+ * ```typescript
118
+ * const unsubscribe = felt.onElementCreate({
119
+ * handler: (element) => console.log(element.id),
120
+ * });
121
+ *
122
+ * // later on...
123
+ * unsubscribe();
124
+ * ```
125
+ */
126
+ onElementCreate(args: {
127
+ /**
128
+ * The handler that is called when an element is created.
129
+ *
130
+ * This will fire when elements are created programatically, or when the
131
+ * user starts creating an element with a drawing tool.
132
+ *
133
+ * When the user creates an element with a drawing tool, it can begin in
134
+ * an invalid state, such as if you've just placed a single point in a polygon.
135
+ *
136
+ * You can use the `isBeingCreated` property to determine if the element is
137
+ * still being created by a drawing tool.
138
+ *
139
+ * If you want to know when the element is finished being created, you can
140
+ * use the {@link ElementsController.onElementCreateEnd | `onElementCreateEnd`} listener.
141
+ *
142
+ * @param change - An object describing the change that occurred.
143
+ */
144
+ handler: (change: ElementChangeCallbackParams) => void;
145
+ }): VoidFunction;
146
+ /**
147
+ * Listens for when a new element is finished being created by a drawing tool.
148
+ *
149
+ * This differs from the {@link ElementsController.onElementCreate | `onElementCreate`} listener, which fires whenever an
150
+ * element is first created. This fires when the user finishes creating an element
151
+ * which could be after a series of interactions.
152
+ *
153
+ * For example, when creating a polygon, the user places a series of points then
154
+ * finishes by pressing Enter or Escape. Or when creating a Place element, they
155
+ * add the marker, type a label, then finally deselect the element.
156
+ *
157
+ * @returns A function to unsubscribe from the listener
158
+ *
159
+ * @event
160
+ * @example
161
+ * ```typescript
162
+ * const unsubscribe = felt.onToolCreatedElement({
163
+ * handler: (params) => console.log(params),
164
+ * });
165
+ *
166
+ * // later on...
167
+ * unsubscribe();
168
+ * ```
169
+ */
170
+ onElementCreateEnd(args: {
171
+ /**
172
+ * The handler to call whenever this event fires.
173
+ *
174
+ * @param params - An object containing the element that was created.
175
+ */
176
+ handler: (params: {
177
+ element: Element;
178
+ }) => void;
179
+ }): VoidFunction;
94
180
  /**
95
181
  * Adds a listener for when an element changes.
96
182
  *
183
+ * This will fire when an element is being edited, either on the map by the user
184
+ * or programatically.
185
+ *
186
+ * Like the {@link ElementsController.onElementCreate | `onElementCreate`} listener, this will fire when an element is
187
+ * still being created by a drawing tool.
188
+ *
189
+ * You can check the {@link ElementChangeCallbackParams.isBeingCreated | `isBeingCreated`} property to determine if the element is
190
+ * still being created by a drawing tool.
191
+ *
97
192
  * @returns A function to unsubscribe from the listener
98
193
  *
99
194
  * @event
@@ -124,6 +219,35 @@ interface ElementsController {
124
219
  */
125
220
  change: ElementChangeCallbackParams) => void;
126
221
  }): VoidFunction;
222
+ /**
223
+ * Adds a listener for when an element is deleted.
224
+ *
225
+ * @returns A function to unsubscribe from the listener
226
+ *
227
+ * @event
228
+ * @example
229
+ * ```typescript
230
+ * const unsubscribe = felt.onElementDelete({
231
+ * options: { id: "element-1" },
232
+ * handler: () => console.log("element-1 deleted"),
233
+ * });
234
+ *
235
+ * // later on...
236
+ * unsubscribe();
237
+ * ```
238
+ */
239
+ onElementDelete(args: {
240
+ options: {
241
+ /**
242
+ * The id of the element to listen for deletions of.
243
+ */
244
+ id: string;
245
+ };
246
+ /**
247
+ * The handler that is called when the element is deleted.
248
+ */
249
+ handler: () => void;
250
+ }): VoidFunction;
127
251
  /**
128
252
  * Adds a listener for when an element group changes.
129
253
  *
@@ -147,6 +271,44 @@ interface ElementsController {
147
271
  };
148
272
  handler: (change: ElementGroupChangeCallbackParams) => void;
149
273
  }): VoidFunction;
274
+ /**
275
+ * Create a new element on the map.
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
280
+ * ```
281
+ */
282
+ createElement(element: ElementCreate): Promise<Element>;
283
+ /**
284
+ * Update an element on the map.
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * // Update a place element's coordinates
289
+ * await felt.updateElement({
290
+ * id: "element-1",
291
+ * coordinates: [10, 20]
292
+ * });
293
+ *
294
+ * // Update a polygon's style
295
+ * await felt.updateElement({
296
+ * id: "element-2",
297
+ * color: "#ABC123",
298
+ * fillOpacity: 0.5
299
+ * });
300
+ * ```
301
+ */
302
+ updateElement(element: ElementUpdate): Promise<Element>;
303
+ /**
304
+ * Delete an element from the map.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * await felt.deleteElement("element-1");
309
+ * ```
310
+ */
311
+ deleteElement(id: string): Promise<void>;
150
312
  }
151
313
 
152
314
  /**
@@ -165,7 +327,7 @@ interface LayersController {
165
327
  *
166
328
  * @example
167
329
  * ```typescript
168
- * const layers = await felt.getLayer({ ids: ["layer-1", "layer-2"] });
330
+ * const layer = await felt.getLayer("layer-1");
169
331
  * ```
170
332
  * @returns The requested layer.
171
333
  */
@@ -281,12 +443,60 @@ interface LayersController {
281
443
  */
282
444
  change: LayerChangeCallbackParams) => void;
283
445
  }): VoidFunction;
446
+ /**
447
+ * Adds layers to the map from file or URL sources.
448
+ *
449
+ * @remarks This allows you to add temporary layers to the map that don't depend on
450
+ * any processing by Felt. This is useful for viewing data from external sources or
451
+ * remote files.
452
+ *
453
+ * @returns The layer groups that were created.
454
+ *
455
+ * @example
456
+ * ```typescript
457
+ * const layerFromFile = await felt.createLayersFromGeoJson({
458
+ * source: {
459
+ * type: "geoJsonFile",
460
+ * file: someFile,
461
+ * },
462
+ * name: "Parcels",
463
+ * });
464
+ *
465
+ * const layerFromUrl = await felt.createLayersFromGeoJson({
466
+ * source: {
467
+ * sourceType: "geoJsonUrl",
468
+ * url: "https://example.com/parcels.geojson",
469
+ * },
470
+ * name: "Parcels",
471
+ * ```
472
+ */
473
+ createLayersFromGeoJson(params: CreateLayersFromGeoJsonParams): Promise<{
474
+ /**
475
+ * The layer group that was created containing the created layers.
476
+ */
477
+ layerGroup: LayerGroup;
478
+ /**
479
+ * The layers that were created from the source.
480
+ */
481
+ layers: Array<Layer>;
482
+ } | null>;
483
+ /**
484
+ * Delete a layer from the map by its id.
485
+ *
486
+ * @remarks This only works for layers created via the SDK `createLayersFromGeoJson` method, not layers added via the Felt UI.
487
+ *
488
+ * @example
489
+ * ```typescript
490
+ * await felt.deleteLayer("layer-1");
491
+ * ```
492
+ */
493
+ deleteLayer(id: string): Promise<void>;
284
494
  /**
285
495
  * Get a layer group from the map by its id.
286
496
  *
287
497
  * @example
288
498
  * ```typescript
289
- * felt.getLayerGroup("layer-group-1");
499
+ * const layerGroup = await felt.getLayerGroup("layer-group-1");
290
500
  * ```
291
501
  * @returns The requested layer group.
292
502
  */
@@ -426,7 +636,7 @@ interface LayersController {
426
636
  *
427
637
  * @example
428
638
  * ```typescript
429
- * felt.setLayerFilters({
639
+ * await felt.setLayerFilters({
430
640
  * layerId: "layer-1",
431
641
  * filters: ["AREA", "gt", 30_000],
432
642
  * });
@@ -449,6 +659,41 @@ interface LayersController {
449
659
  */
450
660
  note?: string;
451
661
  }): Promise<void>;
662
+ /**
663
+ * Adds a listener for when a layer's filters change.
664
+ *
665
+ * @returns A function to unsubscribe from the listener
666
+ *
667
+ * @remarks
668
+ * This event fires whenever any type of filter changes on the layer, including
669
+ * ephemeral filters set via the SDK, style-based filters, or filters set through
670
+ * the Felt UI via Components.
671
+ *
672
+ * @event
673
+ * @example
674
+ * ```typescript
675
+ * const unsubscribe = felt.onLayerFiltersChange({
676
+ * options: { layerId: "layer-1" },
677
+ * handler: ({combined, ephemeral, style, components}) => {
678
+ * console.log("Layer filters updated:", {
679
+ * combined, // All filters combined
680
+ * ephemeral, // Filters set via SDK
681
+ * style, // Filters from layer style
682
+ * components // Filters from UI components
683
+ * });
684
+ * },
685
+ * });
686
+ *
687
+ * // later on...
688
+ * unsubscribe();
689
+ * ```
690
+ */
691
+ onLayerFiltersChange(params: {
692
+ options: {
693
+ layerId: string;
694
+ };
695
+ handler: (change: LayerFilters) => void;
696
+ }): VoidFunction;
452
697
  /**
453
698
  * Get the features that are currently **rendered** on the map in the viewport.
454
699
  *
@@ -466,7 +711,209 @@ interface LayersController {
466
711
  /**
467
712
  * The constraints to apply to the features returned from the map.
468
713
  */
469
- params?: GetRenderedFeaturesConstraint): Promise<Array<Feature>>;
714
+ params?: GetRenderedFeaturesConstraint): Promise<Array<LayerFeature>>;
715
+ /**
716
+ * Get a feature from the map by its ID and layer ID.
717
+ *
718
+ * The response is a {@link LayerFeature} object, which does not include the
719
+ * geometry of the feature.
720
+ *
721
+ * You may want to use this when you don't need the geometry of a feature,
722
+ * but you know the ID of the feature you need.
723
+ *
724
+ * @example
725
+ * ```typescript
726
+ * const feature = await felt.getFeature({ layerId: "layer-1", id: 123 });
727
+ * ```
728
+ */
729
+ getFeature(params: {
730
+ id: string | number;
731
+ layerId: string;
732
+ }): Promise<LayerFeature | null>;
733
+ /**
734
+ * Get a feature in GeoJSON format from the map by its ID and layer ID.
735
+ *
736
+ * The response is a GeoJSON Feature object with the complete geometry of the
737
+ * feature. Note that for some _very_ large geometries, the response may take a
738
+ * long time to return, and may return a very large object.
739
+ *
740
+ * @example
741
+ * ```typescript
742
+ * const feature = await felt.getGeoJsonFeature({ layerId: "layer-1", id: 123 });
743
+ * ```
744
+ */
745
+ getGeoJsonFeature(params: {
746
+ id: string | number;
747
+ layerId: string;
748
+ }): Promise<GeoJsonFeature | null>;
749
+ /**
750
+ * Gets values from a layer grouped by a given attribute.
751
+ *
752
+ * @remarks
753
+ * Groups features in your layer by unique values in the specified attribute and calculates
754
+ * a value for each group. By default, this value is the count of features in each group.
755
+ *
756
+ * You can apply filters in two ways:
757
+ * 1. At the top level (using `boundary` and `filters`), which affects both what categories
758
+ * are included and how values are calculated
759
+ * 2. In the `values` configuration, which only affects the values but keeps all categories
760
+ *
761
+ * This two-level filtering is particularly useful when you want to compare subsets of data
762
+ * while maintaining consistent categories. For example, you might want to show the distribution
763
+ * of all building types in a city, but only count buildings built after 2000 in each category.
764
+ *
765
+ * @example
766
+ * ```typescript
767
+ * // Basic grouping: Count of buildings by type
768
+ * const buildingsByType = await felt.getCategoryData({
769
+ * layerId: "buildings",
770
+ * attribute: "type"
771
+ * });
772
+ *
773
+ * // Filtered grouping: Only count buildings in downtown
774
+ * const downtownBuildingsByType = await felt.getCategoryData({
775
+ * layerId: "buildings",
776
+ * attribute: "type",
777
+ * boundary: [-122.43, 47.60, -122.33, 47.62] // downtown boundary
778
+ * });
779
+ *
780
+ * // Advanced: Show all building types, but only sum floor area of recent buildings
781
+ * const recentBuildingAreaByType = await felt.getCategoryData({
782
+ * layerId: "buildings",
783
+ * attribute: "type",
784
+ * values: {
785
+ * filters: ["year_built", "gte", 2000],
786
+ * aggregation: {
787
+ * method: "sum",
788
+ * attribute: "floor_area"
789
+ * }
790
+ * }
791
+ * });
792
+ *
793
+ * // Compare residential density across neighborhoods while only counting recent buildings
794
+ * const newBuildingDensityByNeighborhood = await felt.getCategoryData({
795
+ * layerId: "buildings",
796
+ * attribute: "neighborhood",
797
+ * values: {
798
+ * filters: ["year_built", "gte", 2000],
799
+ * aggregation: {
800
+ * method: "avg",
801
+ * attribute: "units_per_acre"
802
+ * }
803
+ * }
804
+ * });
805
+ * ```
806
+ */
807
+ getCategoryData(params: GetLayerCategoriesParams): Promise<Array<GetLayerCategoriesGroup>>;
808
+ /**
809
+ * Gets a histogram of values from a layer for a given attribute.
810
+ *
811
+ * @remarks
812
+ * Creates bins (ranges) for numeric data and counts how many features fall into each bin,
813
+ * or returns aggregated values for each bin.
814
+ *
815
+ * You can control how the bins are created using the `steps` parameter, choosing from
816
+ * several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing
817
+ * in the step values directly if you know how you want to bin the data.
818
+ *
819
+ * Like getCategoryData, you can apply filters in two ways:
820
+ * 1. At the top level (using `boundary` and `filters`), which affects both how the bins
821
+ * are calculated and what features are counted in each bin
822
+ * 2. In the `values` configuration, which only affects what gets counted but keeps the
823
+ * bin ranges the same
824
+ *
825
+ * This is particularly useful when you want to compare distributions while keeping
826
+ * consistent bin ranges. For example, you might want to compare the distribution of
827
+ * building heights in different years while using the same height ranges.
828
+ *
829
+ * @example
830
+ * ```typescript
831
+ * // Basic histogram: Building heights in 5 natural break bins
832
+ * const buildingHeights = await felt.getHistogramData({
833
+ * layerId: "buildings",
834
+ * attribute: "height",
835
+ * steps: { type: "jenks", count: 5 }
836
+ * });
837
+ *
838
+ * // Compare old vs new buildings using the same height ranges
839
+ * const oldBuildingHeights = await felt.getHistogramData({
840
+ * layerId: "buildings",
841
+ * attribute: "height",
842
+ * steps: [0, 20, 50, 100, 200, 500],
843
+ * values: {
844
+ * filters: ["year_built", "lt", 1950]
845
+ * }
846
+ * });
847
+ *
848
+ * const newBuildingHeights = await felt.getHistogramData({
849
+ * layerId: "buildings",
850
+ * attribute: "height",
851
+ * steps: [0, 20, 50, 100, 200, 500], // Same ranges as above
852
+ * values: {
853
+ * filters: ["year_built", "gte", 1950]
854
+ * }
855
+ * });
856
+ * ```
857
+ */
858
+ getHistogramData(params: GetLayerHistogramParams): Promise<Array<GetLayerHistogramBin>>;
859
+ /**
860
+ * Calculates a single aggregate value for a layer based on the provided configuration.
861
+ *
862
+ * @remarks
863
+ * Performs statistical calculations on your data, like counting features or computing
864
+ * averages, sums, etc. You can focus your calculation on specific areas or subsets
865
+ * of your data using boundaries and filters.
866
+ *
867
+ * When no aggregation is specified, it counts features. When an aggregation is provided,
868
+ * it performs that calculation (average, sum, etc.) on the specified attribute.
869
+ *
870
+ * @example
871
+ * ```typescript
872
+ * // Count all residential buildings
873
+ * const residentialCount = await felt.getAggregates({
874
+ * layerId: "buildings",
875
+ * filters: ["type", "eq", "residential"]
876
+ * });
877
+ *
878
+ * // Calculate average home value in a specific neighborhood
879
+ * const avgHomeValue = await felt.getAggregates({
880
+ * layerId: "buildings",
881
+ * boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
882
+ * aggregation: {
883
+ * method: "avg",
884
+ * attribute: "assessed_value"
885
+ * }
886
+ * });
887
+ *
888
+ * // Find the maximum building height for buildings built after 2000
889
+ * const maxNewBuildingHeight = await felt.getAggregates({
890
+ * layerId: "buildings",
891
+ * filters: ["year_built", "gte", 2000],
892
+ * aggregation: {
893
+ * method: "max",
894
+ * attribute: "height"
895
+ * }
896
+ * });
897
+ * ```
898
+ */
899
+ getAggregates<T extends AggregationMethod | "count">(params: GetLayerCalculationParams<T>): Promise<Record<T, number | null>>;
900
+ /**
901
+ * Get the schema for a layer.
902
+ *
903
+ * @remarks
904
+ * The schema describes the structure of the data in a layer, including the attributes
905
+ * that are available on the features in the layer.
906
+ *
907
+ * This can be useful to build generic UIs that need to know the structure of the data in
908
+ * a layer, such as a dropdown to choose an attribute.
909
+ *
910
+ * @example
911
+ * ```typescript
912
+ * const schema = await felt.getLayerSchema({ layerId: "layer-1" });
913
+ * const attributeIds = schema.attributes.map((attr) => attr.id);
914
+ * ```
915
+ */
916
+ getLayerSchema(layerId: string): Promise<LayerSchema>;
470
917
  }
471
918
 
472
919
  /**
@@ -503,8 +950,12 @@ interface InteractionsController {
503
950
  * @event
504
951
  * @example
505
952
  * ```typescript
953
+ * // Track mouse movement and features under cursor
506
954
  * const unsubscribe = felt.onPointerMove({
507
- * handler: (event) => console.log(event.center, event.features),
955
+ * handler: (event) => {
956
+ * console.log("Mouse position:", event.center);
957
+ * console.log("Features under cursor:", event.features);
958
+ * }
508
959
  * });
509
960
  *
510
961
  * // later on...
@@ -523,6 +974,27 @@ interface InteractionsController {
523
974
  }): VoidFunction;
524
975
  }
525
976
 
977
+ /**
978
+ * @group Controller
979
+ * @public
980
+ */
981
+ interface MiscController {
982
+ /**
983
+ * Gets the details of the map.
984
+ *
985
+ * @example
986
+ * ```typescript
987
+ * const details = await felt.getMapDetails();
988
+ * console.log({
989
+ * id: details.id,
990
+ * title: details.title,
991
+ * description: details.description,
992
+ * });
993
+ * ```
994
+ */
995
+ getMapDetails(): Promise<MapDetails>;
996
+ }
997
+
526
998
  /**
527
999
  * The Selection controller allows you to listen for changes to the selection on the map.
528
1000
  *
@@ -637,12 +1109,12 @@ interface ToolsController {
637
1109
  * @param tool - The tool to set.
638
1110
  *
639
1111
  * @example
640
- * ```ts
1112
+ * ```typescript
641
1113
  * // Set the tool to "marker"
642
- * felt.setTool("marker");
1114
+ * await felt.setTool("marker");
643
1115
  *
644
1116
  * // put down the tool
645
- * felt.setTool(null);
1117
+ * await felt.setTool(null);
646
1118
  * ```
647
1119
  */
648
1120
  setTool(tool: ToolType | null): void;
@@ -652,7 +1124,7 @@ interface ToolsController {
652
1124
  * @returns The current tool, or `null` if no tool is in use.
653
1125
  *
654
1126
  * @example
655
- * ```ts
1127
+ * ```typescript
656
1128
  * const tool = await felt.getTool(); // "marker", "polygon", etc.
657
1129
  * ```
658
1130
  */
@@ -663,7 +1135,7 @@ interface ToolsController {
663
1135
  * @returns A function to unsubscribe from the listener
664
1136
  *
665
1137
  * @example
666
- * ```ts
1138
+ * ```typescript
667
1139
  * const unsubscribe = felt.onToolChange({
668
1140
  * handler: tool => console.log(tool),
669
1141
  * });
@@ -683,18 +1155,41 @@ interface ToolsController {
683
1155
  /**
684
1156
  * Sets the settings for the current tool.
685
1157
  *
1158
+ * @example
1159
+ * ```typescript
1160
+ * // Set the settings for the marker tool
1161
+ * await felt.setToolSettings({
1162
+ * tool: "marker",
1163
+ * color: "#FE17",
1164
+ * });
1165
+ * ```
1166
+ *
686
1167
  * @param settings - The settings to set.
687
1168
  */
688
1169
  setToolSettings(settings: InputToolSettings): void;
689
1170
  /**
690
- * Gets the settings for the current tool.
1171
+ * Gets the settings for the chosen tool
1172
+ *
1173
+ * @example
1174
+ * ```typescript
1175
+ * const settings = await felt.getToolSettings("marker");
1176
+ * ```
691
1177
  *
692
- * @returns The settings for the current tool.
1178
+ * @returns The settings for the chosen tool.
693
1179
  */
694
1180
  getToolSettings<T extends ConfigurableToolType>(tool: T): Promise<ToolSettingsMap[T]>;
695
1181
  /**
696
1182
  * Listens for changes to the settings on all tools.
697
1183
  *
1184
+ * @example
1185
+ * ```typescript
1186
+ * const unsubscribe = felt.onToolSettingsChange({
1187
+ * handler: settings => console.log(settings),
1188
+ * });
1189
+ *
1190
+ * // later on...
1191
+ * unsubscribe();
1192
+ * ```
698
1193
  * @returns A function to unsubscribe from the listener
699
1194
  */
700
1195
  onToolSettingsChange(args: {
@@ -841,8 +1336,10 @@ declare const UiOnMapInteractionsOptionsSchema: z.ZodObject<{
841
1336
  }>;
842
1337
 
843
1338
  /**
844
- * The UI controller allows you to enable and disable UI controls on the
845
- * embedded map.
1339
+ * The UI controller allows you to control various aspects of the Felt UI in your embedded map.
1340
+ *
1341
+ * This includes enabling/disabling UI controls, managing on-map interactions, and controlling
1342
+ * the visibility of UI components like the data table.
846
1343
  *
847
1344
  * @group Controller
848
1345
  * @public
@@ -851,6 +1348,21 @@ interface UiController {
851
1348
  /**
852
1349
  * Updates the UI controls on the embedded map.
853
1350
  *
1351
+ * @example
1352
+ * ```typescript
1353
+ * // Show some UI controls
1354
+ * await felt.updateUiControls({
1355
+ * showLegend: true,
1356
+ * fullScreenButton: true,
1357
+ * });
1358
+ *
1359
+ * // Disable some UI options
1360
+ * await felt.updateUiControls({
1361
+ * cooperativeGestures: false,
1362
+ * geolocation: false,
1363
+ * });
1364
+ * ```
1365
+ *
854
1366
  * @param controls - The controls to update.
855
1367
  */
856
1368
  updateUiControls(controls: UiControlsOptions): void;
@@ -864,8 +1376,53 @@ interface UiController {
864
1376
  *
865
1377
  * This does not affect selection. That means that selectable features and elements
866
1378
  * will still be selected when clicked.
1379
+ *
1380
+ * @example
1381
+ * ```typescript
1382
+ * // Disable UI when hovering or selecting features
1383
+ * await felt.setOnMapInteractionsUi({
1384
+ * featureSelectPanel: false,
1385
+ * featureHoverPanel: false,
1386
+ * });
1387
+ * ```
867
1388
  */
868
1389
  setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void;
1390
+ /**
1391
+ * Shows a data table view for the specified layer, optionally sorted by a given attribute.
1392
+ *
1393
+ * @example
1394
+ * ```typescript
1395
+ * // Show data table with default sorting
1396
+ * await felt.showLayerDataTable({
1397
+ * layerId: "layer-1",
1398
+ * });
1399
+ *
1400
+ * // Show data table sorted by height in descending order
1401
+ * await felt.showLayerDataTable({
1402
+ * layerId: "layer-1",
1403
+ * sorting: {
1404
+ * attribute: "height",
1405
+ * direction: "desc",
1406
+ * },
1407
+ * });
1408
+ *
1409
+ * // Show the data table pane with no table visible
1410
+ * await felt.showLayerDataTable();
1411
+ * ```
1412
+ */
1413
+ showLayerDataTable(params?: {
1414
+ layerId: string;
1415
+ sorting?: SortConfig;
1416
+ }): Promise<void>;
1417
+ /**
1418
+ * Hides the data table.
1419
+ *
1420
+ * @example
1421
+ * ```typescript
1422
+ * await felt.hideLayerDataTable();
1423
+ * ```
1424
+ */
1425
+ hideLayerDataTable(): Promise<void>;
869
1426
  }
870
1427
 
871
1428
  /**
@@ -880,6 +1437,16 @@ interface UiController {
880
1437
  interface ViewportController {
881
1438
  /**
882
1439
  * Gets the current state of the viewport.
1440
+ *
1441
+ * @example
1442
+ * ```typescript
1443
+ * // Get current viewport state
1444
+ * const viewport = await felt.getViewport();
1445
+ * console.log({
1446
+ * center: viewport.center,
1447
+ * zoom: viewport.zoom,
1448
+ * });
1449
+ * ```
883
1450
  */
884
1451
  getViewport(): Promise<ViewportState>;
885
1452
  /**
@@ -896,6 +1463,21 @@ interface ViewportController {
896
1463
  setViewport(viewport: SetViewportCenterZoomParams): void;
897
1464
  /**
898
1465
  * Gets the current state of the viewport constraints.
1466
+ *
1467
+ * @example
1468
+ * ```typescript
1469
+ * // Get current viewport constraints
1470
+ * const constraints = await felt.getViewportConstraints();
1471
+ * if (constraints) {
1472
+ * console.log({
1473
+ * bounds: constraints.bounds,
1474
+ * minZoom: constraints.minZoom,
1475
+ * maxZoom: constraints.maxZoom
1476
+ * });
1477
+ * } else {
1478
+ * console.log("No viewport constraints set");
1479
+ * }
1480
+ * ```
899
1481
  */
900
1482
  getViewportConstraints(): Promise<ViewportConstraints | null>;
901
1483
  /**
@@ -1025,7 +1607,7 @@ interface ViewportController {
1025
1607
  * @group Controller
1026
1608
  * @public
1027
1609
  */
1028
- interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController {
1610
+ interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController, InteractionsController, MiscController {
1029
1611
  /**
1030
1612
  * The iframe element containing the Felt map, if it is an embedded map.
1031
1613
  *
@@ -1179,12 +1761,13 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1179
1761
  */
1180
1762
  declare const Felt: {
1181
1763
  /**
1182
- * Embeds a Felt map into the provided container.
1764
+ * Embeds a Felt map into the provided container, returning a promise that resolves
1765
+ * to a {@link FeltController} object that you can use to control the map.
1183
1766
  *
1184
1767
  * @param container - The container element to embed the map into.
1185
1768
  * @param mapId - The ID of the map to embed.
1186
1769
  * @param options - The options to configure the map.
1187
- * @returns
1770
+ * @returns A promise for a {@link FeltController}.
1188
1771
  */
1189
1772
  embed(container: HTMLElement, mapId: string, options?: FeltEmbedOptions): Promise<FeltController>;
1190
1773
  /**
@@ -1193,7 +1776,7 @@ declare const Felt: {
1193
1776
  * @param feltWindow - The iframe element containing the Felt map.
1194
1777
  * @returns
1195
1778
  */
1196
- connect(feltWindow: Window): Promise<FeltController>;
1779
+ connect(feltWindow: Pick<Window, "postMessage">): Promise<FeltController>;
1197
1780
  };
1198
1781
 
1199
- export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementGroup, ElementGroupChangeCallbackParams, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapInteractionEvent, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
1782
+ export { AggregationMethod, ConfigurableToolType, CreateLayersFromGeoJsonParams, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, GeoJsonFeature, GeoJsonGeometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFeature, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, LayerSchema, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, SortConfig, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };