@feltmaps/js-sdk 1.5.0-next.9 → 1.6.0-next.0

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, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, 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 Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, K as SortConfig, V as ViewportState, N as SetViewportCenterZoomParams, O as ViewportConstraints, P as ViewportFitBoundsParams, Q as ViewportCenterZoom } from './types-6AWHhIPp.js';
2
- export { ap as AggregationConfig, R as CircleElementCreate, U as CircleElementRead, W as CircleElementUpdate, aH as CircleToolSettings, as as ElementGroupNode, at as ElementNode, au as FeatureNode, ax as FeltBoundary, ay as FeltZoom, am as FilterExpression, an as FilterLogicGate, ao as FilterTernary, X as HighlighterElementCreate, Y as HighlighterElementRead, Z as HighlighterElementUpdate, aI as HighlighterToolSettings, _ as ImageElementCreate, $ as ImageElementRead, a0 as ImageElementUpdate, az as LatLng, av as LayerGroupNode, aw as LayerNode, ak as LayerProcessingStatus, aA as LineStringGeometry, aJ as LineToolSettings, a1 as LinkElementRead, aB as LngLatTuple, a2 as MarkerElementCreate, a3 as MarkerElementRead, a4 as MarkerElementUpdate, aK as MarkerToolSettings, aq as MultiAggregationConfig, aC as MultiLineStringGeometry, aD as MultiPolygonGeometry, a5 as NoteElementCreate, a6 as NoteElementRead, a7 as NoteElementUpdate, aL as NoteToolSettings, a8 as PathElementCreate, a9 as PathElementRead, aa as PathElementUpdate, aM as PinToolSettings, ab as PlaceElementCreate, ac as PlaceElementRead, ad as PlaceElementUpdate, aN as PlaceFrame, aO as PlaceSymbol, aE as PointGeometry, ae as PolygonElementCreate, af as PolygonElementRead, ag as PolygonElementUpdate, aF as PolygonGeometry, aP as PolygonToolSettings, al as RasterValue, aQ as RouteToolSettings, aG as SortDirection, ah as TextElementCreate, ai as TextElementRead, aj as TextElementUpdate, aR as TextToolSettings, ar as ValueConfiguration } from './types-6AWHhIPp.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, M as MapInteractionEvent, h as MapDetails, i as EntityNode, F as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, j as ToolSettingsMap, k as ToolSettingsChangeEvent, z as zInfer, l as SortConfig, V as ViewportState, m as SetViewportCenterZoomParams, n as ViewportConstraints, o as ViewportFitBoundsParams, L as LayersController, p as ViewportCenterZoom } from './types-B241Rd9q.js';
2
+ export { aF as AggregationConfig, aG as AggregationMethod, q as CircleElementCreate, r as CircleElementRead, s as CircleElementUpdate, b4 as CircleToolSettings, a1 as CreateLayersFromGeoJsonParams, a2 as DataOnlyLayer, aO as ElementGroupNode, aP as ElementNode, aQ as FeatureNode, aT as FeltBoundary, a3 as FeltTiledVectorSource, aU as FeltZoom, az as FilterExpression, aA as FilterLogicGate, aB as FilterTernary, aC as Filters, a4 as GeoJsonDataVectorSource, aV as GeoJsonFeature, a5 as GeoJsonFileVectorSource, aW as GeoJsonProperties, a6 as GeoJsonUrlVectorSource, aD as GeometryFilter, aH as GetLayerCalculationParams, aI as GetLayerCategoriesGroup, aJ as GetLayerCategoriesParams, a7 as GetLayerGroupsConstraint, aK as GetLayerHistogramBin, aL as GetLayerHistogramParams, a8 as GetLayersConstraint, a9 as GetRenderedFeaturesConstraint, H as HighlighterElementCreate, t as HighlighterElementRead, u as HighlighterElementUpdate, b5 as HighlighterToolSettings, v as ImageElementCreate, w as ImageElementRead, x as ImageElementUpdate, aX as LatLng, aa as Layer, ab as LayerChangeCallbackParams, ac as LayerCommon, ap as LayerFeature, aE as LayerFilters, ad as LayerGroup, ae as LayerGroupChangeCallbackParams, aR as LayerGroupNode, aS as LayerNode, af as LayerProcessingStatus, ar as LayerSchema, as as LayerSchemaAttribute, at as LayerSchemaBooleanAttribute, au as LayerSchemaCommonAttribute, av as LayerSchemaDateAttribute, aw as LayerSchemaDateTimeAttribute, ax as LayerSchemaNumericAttribute, ay as LayerSchemaTextAttribute, ag as LegendItem, ah as LegendItemChangeCallbackParams, ai as LegendItemIdentifier, aj as LegendItemsConstraint, aY as LineStringGeometry, b6 as LineToolSettings, y as LinkElementRead, aZ as LngLatTuple, A as MarkerElementCreate, B as MarkerElementRead, D as MarkerElementUpdate, b7 as MarkerToolSettings, aM as MultiAggregationConfig, a_ as MultiLineStringGeometry, a$ as MultiPointGeometry, b0 as MultiPolygonGeometry, N as NoteElementCreate, J as NoteElementRead, K as NoteElementUpdate, b8 as NoteToolSettings, P as PathElementCreate, O as PathElementRead, Q as PathElementUpdate, b9 as PinToolSettings, R as PlaceElementCreate, U as PlaceElementRead, W as PlaceElementUpdate, ba as PlaceFrame, bb as PlaceSymbol, b1 as PointGeometry, X as PolygonElementCreate, Y as PolygonElementRead, Z as PolygonElementUpdate, b2 as PolygonGeometry, bc as PolygonToolSettings, ak as RasterBand, al as RasterLayer, am as RasterLayerSource, aq as RasterValue, bd as RouteToolSettings, b3 as SortDirection, _ as TextElementCreate, $ as TextElementRead, a0 as TextElementUpdate, be as TextToolSettings, an as UpdateLayerParams, aN as ValueConfiguration, ao as VectorLayer } from './types-B241Rd9q.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.
@@ -121,7 +137,7 @@ interface ElementsController {
121
137
  * still being created by a drawing tool.
122
138
  *
123
139
  * If you want to know when the element is finished being created, you can
124
- * use the `onToolCreateElementEnd` listener.
140
+ * use the {@link ElementsController.onElementCreateEnd | `onElementCreateEnd`} listener.
125
141
  *
126
142
  * @param change - An object describing the change that occurred.
127
143
  */
@@ -130,7 +146,7 @@ interface ElementsController {
130
146
  /**
131
147
  * Listens for when a new element is finished being created by a drawing tool.
132
148
  *
133
- * This differs from the `onElementCreate` listener, which fires whenever an
149
+ * This differs from the {@link ElementsController.onElementCreate | `onElementCreate`} listener, which fires whenever an
134
150
  * element is first created. This fires when the user finishes creating an element
135
151
  * which could be after a series of interactions.
136
152
  *
@@ -140,6 +156,7 @@ interface ElementsController {
140
156
  *
141
157
  * @returns A function to unsubscribe from the listener
142
158
  *
159
+ * @event
143
160
  * @example
144
161
  * ```typescript
145
162
  * const unsubscribe = felt.onToolCreatedElement({
@@ -166,10 +183,10 @@ interface ElementsController {
166
183
  * This will fire when an element is being edited, either on the map by the user
167
184
  * or programatically.
168
185
  *
169
- * Like the `onElementCreate` listener, this will fire when an element is
186
+ * Like the {@link ElementsController.onElementCreate | `onElementCreate`} listener, this will fire when an element is
170
187
  * still being created by a drawing tool.
171
188
  *
172
- * You can check the `isBeingCreated` property to determine if the element is
189
+ * You can check the {@link ElementChangeCallbackParams.isBeingCreated | `isBeingCreated`} property to determine if the element is
173
190
  * still being created by a drawing tool.
174
191
  *
175
192
  * @returns A function to unsubscribe from the listener
@@ -212,7 +229,7 @@ interface ElementsController {
212
229
  * ```typescript
213
230
  * const unsubscribe = felt.onElementDelete({
214
231
  * options: { id: "element-1" },
215
- * handler: (element) => console.log(element.id),
232
+ * handler: () => console.log("element-1 deleted"),
216
233
  * });
217
234
  *
218
235
  * // later on...
@@ -265,518 +282,33 @@ interface ElementsController {
265
282
  createElement(element: ElementCreate): Promise<Element>;
266
283
  /**
267
284
  * Update an element on the map.
268
- */
269
- updateElement(element: ElementUpdate): Promise<Element>;
270
- /**
271
- * Delete an element from the map.
272
- */
273
- deleteElement(id: string): Promise<void>;
274
- }
275
-
276
- /**
277
- * The Layers controller allows you to get information about the layers on the
278
- * map, and make changes to their visibility.
279
- *
280
- * Layers can be organised into groups, and their groups can also have their
281
- * visibility toggled.
282
- *
283
- * @group Controller
284
- * @public
285
- */
286
- interface LayersController {
287
- /**
288
- * Get a single layer from the map by its id.
289
- *
290
- * @example
291
- * ```typescript
292
- * const layer = await felt.getLayer("layer-1");
293
- * ```
294
- * @returns The requested layer.
295
- */
296
- getLayer(
297
- /**
298
- * The id of the layer you want to get.
299
- */
300
- id: string): Promise<Layer | null>;
301
- /**
302
- * Gets layers from the map, according to the constraints supplied. If no
303
- * constraints are supplied, all layers will be returned.
304
- *
305
- * @remarks The layers in the map, ordered by the order specified in Felt. This is not
306
- * necessarily the order that they are drawn in, as Felt draws points above
307
- * lines and lines above polygons, for instance.
308
- *
309
- * @example
310
- * ```typescript
311
- * const layers = await felt.getLayers();
312
- * ```
313
- * @returns All layers on the map.
314
- */
315
- getLayers(
316
- /**
317
- * The constraints to apply to the layers returned from the map.
318
- */
319
- constraint?: GetLayersConstraint): Promise<Array<Layer | null>>;
320
- /**
321
- * Hide or show layers with the given ids.
322
- *
323
- * @example
324
- * ```typescript
325
- * felt.setLayerVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
326
- * ```
327
- */
328
- setLayerVisibility(visibility: SetVisibilityRequest): Promise<void>;
329
- /**
330
- * Set the style for a layer using FSL, the Felt Style Language.
331
- *
332
- * Changes are only for this session, and not persisted. This is useful to make
333
- * temporary changes to a layer's style, such as to highlight a particular layer
334
- * or feature.
335
- *
336
- * See the [FSL documentation](https://developers.felt.com/felt-style-language) for details
337
- * on how to read and write styles.
338
- *
339
- * If the style you set is invalid, you will receive an error explaining the problem
340
- * in the rejected promise value.
341
- *
342
- * @example
343
- * ```typescript
344
- * // first get the current style
345
- * const oldStyle = (await felt.getLayer("layer-1")).style;
346
- *
347
- * felt.setLayerStyle({ id: "layer-1", style: {
348
- * ...oldStyle,
349
- * paint: {
350
- * ...oldStyle.paint,
351
- * color: "red",
352
- * },
353
- * } });
354
- * ```
355
- */
356
- setLayerStyle(params: {
357
- /**
358
- * The id of the layer to set the style for.
359
- */
360
- id: string;
361
- /**
362
- * The style to set for the layer.
363
- */
364
- style: object;
365
- }): Promise<void>;
366
- /**
367
- * Hide or show layers with the given ids from the legend.
368
- *
369
- * @example
370
- * ```typescript
371
- * felt.setLayerLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
372
- * ```
373
- */
374
- setLayerLegendVisibility(params: SetVisibilityRequest): Promise<void>;
375
- /**
376
- * Adds a listener for when a layer changes.
377
285
  *
378
- * @returns A function to unsubscribe from the listener
379
- *
380
- * @event
381
286
  * @example
382
287
  * ```typescript
383
- * const unsubscribe = felt.onLayerChange({
384
- * options: { id: "layer-1" },
385
- * handler: ({layer}) => console.log(layer.bounds),
288
+ * // Update a place element's coordinates
289
+ * await felt.updateElement({
290
+ * id: "element-1",
291
+ * coordinates: [10, 20]
386
292
  * });
387
293
  *
388
- * // later on...
389
- * unsubscribe();
390
- * ```
391
- */
392
- onLayerChange(args: {
393
- options: {
394
- /**
395
- * The id of the layer to listen for changes to.
396
- */
397
- id: string;
398
- };
399
- /**
400
- * The handler that is called when the layer changes.
401
- */
402
- handler: (
403
- /**
404
- * An object describing the change that occurred.
405
- */
406
- change: LayerChangeCallbackParams) => void;
407
- }): VoidFunction;
408
- /**
409
- * Get a layer group from the map by its id.
410
- *
411
- * @example
412
- * ```typescript
413
- * const layerGroup = await felt.getLayerGroup("layer-group-1");
414
- * ```
415
- * @returns The requested layer group.
416
- */
417
- getLayerGroup(id: string): Promise<LayerGroup | null>;
418
- /**
419
- * Gets layer groups from the map, according to the constraints supplied. If no
420
- * constraints are supplied, all layer groups will be returned in rendering order.
421
- *
422
- * @example
423
- * ```typescript
424
- * const layerGroups = await felt.getLayerGroups({ ids: ["layer-group-1", "layer-group-2"] });
425
- * ```
426
- * @returns The requested layer groups.
427
- */
428
- getLayerGroups(
429
- /**
430
- * The constraints to apply to the layer groups returned from the map.
431
- */
432
- constraint?: GetLayerGroupsConstraint): Promise<Array<LayerGroup | null>>;
433
- /**
434
- * Hide or show layer groups with the given ids.
435
- *
436
- * @example
437
- * ```typescript
438
- * felt.setLayerGroupVisibility({ show: ["layer-group-1", "layer-group-2"], hide: ["layer-group-3"] });
439
- * ```
440
- */
441
- setLayerGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
442
- /**
443
- * Hide or show layer groups with the given ids from the legend.
444
- *
445
- * @example
446
- * ```typescript
447
- * felt.setLayerGroupLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
448
- * ```
449
- */
450
- setLayerGroupLegendVisibility(params: SetVisibilityRequest): Promise<void>;
451
- /**
452
- * Adds a listener for when a layer group changes.
453
- *
454
- * @returns A function to unsubscribe from the listener
455
- *
456
- * @event
457
- * @example
458
- * ```typescript
459
- * const unsubscribe = felt.onLayerGroupChange({
460
- * options: { id: "layer-group-1" },
461
- * handler: ({layerGroup}) => console.log(layerGroup.id),
294
+ * // Update a polygon's style
295
+ * await felt.updateElement({
296
+ * id: "element-2",
297
+ * color: "#ABC123",
298
+ * fillOpacity: 0.5
462
299
  * });
463
- *
464
- * // later on...
465
- * unsubscribe();
466
- * ```
467
- */
468
- onLayerGroupChange(args: {
469
- options: {
470
- id: string;
471
- };
472
- handler: (change: LayerGroupChangeCallbackParams) => void;
473
- }): VoidFunction;
474
- /**
475
- * Allows you to get the state of a single legend item.
476
- *
477
- * @example
478
- * ```typescript
479
- * const legendItem = await felt.getLegendItem({
480
- * id: "legend-item-1",
481
- * layerId: "layer-1",
482
- * })
483
- * ```
484
- */
485
- getLegendItem(id: LegendItemIdentifier): Promise<LegendItem | null>;
486
- /**
487
- * Allows you to obtain the state of several legend items, by passing in
488
- * constraints describing which legend items you want.
489
- *
490
- * If you do not pass any constraints, you will receive all legend items.
491
- *
492
- * @example
493
- * ```typescript
494
- * const legendItems = await felt.getLegendItems({layerId: "layer-1"});
495
- * ```
496
- */
497
- getLegendItems(constraint?: LegendItemsConstraint): Promise<Array<LegendItem | null>>;
498
- /**
499
- * Hide or show legend items with the given identifiers.
500
- *
501
- * @example
502
- * ```typescript
503
- * felt.setLegendItemVisibility({
504
- * show: [{layerId: "layer-group-1", id: "item-1-0"}],
505
- * hide: [{layerId: "layer-group-2", id: "item-2-0"}],
506
- * })
507
300
  * ```
508
301
  */
509
- setLegendItemVisibility(visibility: {
510
- show?: Array<LegendItemIdentifier>;
511
- hide?: Array<LegendItemIdentifier>;
512
- }): Promise<void>;
513
- /**
514
- * Adds a listener for when a legend item changes.
515
- *
516
- * @returns A function to unsubscribe from the listener
517
- *
518
- * @event
519
- * @example
520
- * ```typescript
521
- * const unsubscribe = felt.onLegendItemChange({
522
- * options: { layerId: "layer-1", id: "item-1-0" },
523
- * handler: ({legendItem}) => console.log(legendItem.visible),
524
- * });
525
- *
526
- * // later on...
527
- * unsubscribe();
528
- * ```
529
- */
530
- onLegendItemChange(args: {
531
- options: LegendItemIdentifier;
532
- handler: (change: LegendItemChangeCallbackParams) => void;
533
- }): VoidFunction;
534
- /**
535
- * Get the filters for a layer.
536
- *
537
- * @remarks
538
- * The return type gives you the filters split up into the various sources
539
- * that make up the overall filters for a layer.
540
- *
541
- * @example
542
- * ```typescript
543
- * const filters = await felt.getLayerFilters("layer-1");
544
- * console.log(filters.combined, filters.style, filters.ephemeral, filters.components);
545
- * ```
546
- */
547
- getLayerFilters(layerId: string): Promise<LayerFilters | null>;
548
- /**
549
- * Sets the **ephemeral** filters for a layer.
550
- *
551
- * @example
552
- * ```typescript
553
- * felt.setLayerFilters({
554
- * layerId: "layer-1",
555
- * filters: ["AREA", "gt", 30_000],
556
- * });
557
- * ```
558
- */
559
- setLayerFilters(params: {
560
- /**
561
- * The layer that you want to set the filters for.
562
- */
563
- layerId: string;
564
- /**
565
- * The filters to set for the layer. This will replace any ephemeral filters
566
- * that are currently set for the layer.
567
- */
568
- filters: Filters;
569
- /**
570
- * A note to display on the layer legend when this filter is applied. When the
571
- * note is shown, a reset button will also be shown, allowing the user to clear
572
- * the filter.
573
- */
574
- note?: string;
575
- }): Promise<void>;
576
- /**
577
- * Adds a listener for when a layer's filters change.
578
- *
579
- * @returns A function to unsubscribe from the listener
580
- *
581
- * @remarks
582
- * This event fires whenever any type of filter changes on the layer, including
583
- * ephemeral filters set via the SDK, style-based filters, or filters set through
584
- * the Felt UI via Components.
585
- *
586
- * @event
587
- * @example
588
- * ```typescript
589
- * const unsubscribe = felt.onLayerFiltersChange({
590
- * options: { layerId: "layer-1" },
591
- * handler: ({combined, ephemeral, style, components}) => {
592
- * console.log("Layer filters updated:", {
593
- * combined, // All filters combined
594
- * ephemeral, // Filters set via SDK
595
- * style, // Filters from layer style
596
- * components // Filters from UI components
597
- * });
598
- * },
599
- * });
600
- *
601
- * // later on...
602
- * unsubscribe();
603
- * ```
604
- */
605
- onLayerFiltersChange(params: {
606
- options: {
607
- layerId: string;
608
- };
609
- handler: (change: LayerFilters) => void;
610
- }): VoidFunction;
611
- /**
612
- * Get the features that are currently **rendered** on the map in the viewport.
613
- *
614
- * Note that this is explicitly about the features that are rendered, which isn't
615
- * necessarily a complete list of all the features in the viewport. This is because
616
- * of the way features are tiled: at low zoom levels or high feature densities, many
617
- * features are omitted from what is rendered on the screen.
618
- *
619
- * @example
620
- * ```typescript
621
- * const features = await felt.getRenderedFeatures();
622
- * ```
623
- */
624
- getRenderedFeatures(
625
- /**
626
- * The constraints to apply to the features returned from the map.
627
- */
628
- params?: GetRenderedFeaturesConstraint): Promise<Array<Feature>>;
629
- /**
630
- * Gets values from a layer grouped by a given attribute.
631
- *
632
- * @remarks
633
- * Groups features in your layer by unique values in the specified attribute and calculates
634
- * a value for each group. By default, this value is the count of features in each group.
635
- *
636
- * You can apply filters in two ways:
637
- * 1. At the top level (using `boundary` and `filters`), which affects both what categories
638
- * are included and how values are calculated
639
- * 2. In the `values` configuration, which only affects the values but keeps all categories
640
- *
641
- * This two-level filtering is particularly useful when you want to compare subsets of data
642
- * while maintaining consistent categories. For example, you might want to show the distribution
643
- * of all building types in a city, but only count buildings built after 2000 in each category.
644
- *
645
- * @example
646
- * ```typescript
647
- * // Basic grouping: Count of buildings by type
648
- * const buildingsByType = await felt.getCategoryData({
649
- * layerId: "buildings",
650
- * attribute: "type"
651
- * });
652
- *
653
- * // Filtered grouping: Only count buildings in downtown
654
- * const downtownBuildingsByType = await felt.getCategoryData({
655
- * layerId: "buildings",
656
- * attribute: "type",
657
- * boundary: [-122.43, 47.60, -122.33, 47.62] // downtown boundary
658
- * });
659
- *
660
- * // Advanced: Show all building types, but only sum floor area of recent buildings
661
- * const recentBuildingAreaByType = await felt.getCategoryData({
662
- * layerId: "buildings",
663
- * attribute: "type",
664
- * values: {
665
- * filters: ["year_built", "gte", 2000],
666
- * aggregation: {
667
- * method: "sum",
668
- * attribute: "floor_area"
669
- * }
670
- * }
671
- * });
672
- *
673
- * // Compare residential density across neighborhoods while only counting recent buildings
674
- * const newBuildingDensityByNeighborhood = await felt.getCategoryData({
675
- * layerId: "buildings",
676
- * attribute: "neighborhood",
677
- * values: {
678
- * filters: ["year_built", "gte", 2000],
679
- * aggregation: {
680
- * method: "avg",
681
- * attribute: "units_per_acre"
682
- * }
683
- * }
684
- * });
685
- * ```
686
- */
687
- getCategoryData(params: GetLayerCategoriesParams): Promise<Array<GetLayerCategoriesGroup>>;
688
- /**
689
- * Gets a histogram of values from a layer for a given attribute.
690
- *
691
- * @remarks
692
- * Creates bins (ranges) for numeric data and counts how many features fall into each bin,
693
- * or returns aggregated values for each bin.
694
- *
695
- * You can control how the bins are created using the `steps` parameter, choosing from
696
- * several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing
697
- * in the step values directly if you know how you want to bin the data.
698
- *
699
- * Like getCategoryData, you can apply filters in two ways:
700
- * 1. At the top level (using `boundary` and `filters`), which affects both how the bins
701
- * are calculated and what features are counted in each bin
702
- * 2. In the `values` configuration, which only affects what gets counted but keeps the
703
- * bin ranges the same
704
- *
705
- * This is particularly useful when you want to compare distributions while keeping
706
- * consistent bin ranges. For example, you might want to compare the distribution of
707
- * building heights in different years while using the same height ranges.
708
- *
709
- * @example
710
- * ```typescript
711
- * // Basic histogram: Building heights in 5 natural break bins
712
- * const buildingHeights = await felt.getHistogramData({
713
- * layerId: "buildings",
714
- * attribute: "height",
715
- * steps: { type: "jenks", count: 5 }
716
- * });
717
- *
718
- * // Compare old vs new buildings using the same height ranges
719
- * const oldBuildingHeights = await felt.getHistogramData({
720
- * layerId: "buildings",
721
- * attribute: "height",
722
- * steps: [0, 20, 50, 100, 200, 500],
723
- * values: {
724
- * filters: ["year_built", "lt", 1950]
725
- * }
726
- * });
727
- *
728
- * const newBuildingHeights = await felt.getHistogramData({
729
- * layerId: "buildings",
730
- * attribute: "height",
731
- * steps: [0, 20, 50, 100, 200, 500], // Same ranges as above
732
- * values: {
733
- * filters: ["year_built", "gte", 1950]
734
- * }
735
- * });
736
- * ```
737
- */
738
- getHistogramData(params: GetLayerHistogramParams): Promise<Array<GetLayerHistogramBin>>;
302
+ updateElement(element: ElementUpdate): Promise<Element>;
739
303
  /**
740
- * Calculates a single aggregate value for a layer based on the provided configuration.
741
- *
742
- * @remarks
743
- * Performs statistical calculations on your data, like counting features or computing
744
- * averages, sums, etc. You can focus your calculation on specific areas or subsets
745
- * of your data using boundaries and filters.
746
- *
747
- * When no aggregation is specified, it counts features. When an aggregation is provided,
748
- * it performs that calculation (average, sum, etc.) on the specified attribute.
304
+ * Delete an element from the map.
749
305
  *
750
306
  * @example
751
307
  * ```typescript
752
- * // Count all residential buildings
753
- * const residentialCount = await felt.getAggregates({
754
- * layerId: "buildings",
755
- * filters: ["type", "eq", "residential"]
756
- * });
757
- *
758
- * // Calculate average home value in a specific neighborhood
759
- * const avgHomeValue = await felt.getAggregates({
760
- * layerId: "buildings",
761
- * boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
762
- * aggregation: {
763
- * method: "avg",
764
- * attribute: "assessed_value"
765
- * }
766
- * });
767
- *
768
- * // Find the maximum building height for buildings built after 2000
769
- * const maxNewBuildingHeight = await felt.getAggregates({
770
- * layerId: "buildings",
771
- * filters: ["year_built", "gte", 2000],
772
- * aggregation: {
773
- * method: "max",
774
- * attribute: "height"
775
- * }
776
- * });
308
+ * await felt.deleteElement("element-1");
777
309
  * ```
778
310
  */
779
- getAggregates<T extends AggregationMethod | "count">(params: GetLayerCalculationParams<T>): Promise<Record<T, number | null>>;
311
+ deleteElement(id: string): Promise<void>;
780
312
  }
781
313
 
782
314
  /**
@@ -813,8 +345,12 @@ interface InteractionsController {
813
345
  * @event
814
346
  * @example
815
347
  * ```typescript
348
+ * // Track mouse movement and features under cursor
816
349
  * const unsubscribe = felt.onPointerMove({
817
- * handler: (event) => console.log(event.center, event.features),
350
+ * handler: (event) => {
351
+ * console.log("Mouse position:", event.center);
352
+ * console.log("Features under cursor:", event.features);
353
+ * }
818
354
  * });
819
355
  *
820
356
  * // later on...
@@ -840,6 +376,16 @@ interface InteractionsController {
840
376
  interface MiscController {
841
377
  /**
842
378
  * Gets the details of the map.
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * const details = await felt.getMapDetails();
383
+ * console.log({
384
+ * id: details.id,
385
+ * title: details.title,
386
+ * description: details.description,
387
+ * });
388
+ * ```
843
389
  */
844
390
  getMapDetails(): Promise<MapDetails>;
845
391
  }
@@ -960,10 +506,10 @@ interface ToolsController {
960
506
  * @example
961
507
  * ```typescript
962
508
  * // Set the tool to "marker"
963
- * felt.setTool("marker");
509
+ * await felt.setTool("marker");
964
510
  *
965
511
  * // put down the tool
966
- * felt.setTool(null);
512
+ * await felt.setTool(null);
967
513
  * ```
968
514
  */
969
515
  setTool(tool: ToolType | null): void;
@@ -1004,18 +550,41 @@ interface ToolsController {
1004
550
  /**
1005
551
  * Sets the settings for the current tool.
1006
552
  *
553
+ * @example
554
+ * ```typescript
555
+ * // Set the settings for the marker tool
556
+ * await felt.setToolSettings({
557
+ * tool: "marker",
558
+ * color: "#FE17",
559
+ * });
560
+ * ```
561
+ *
1007
562
  * @param settings - The settings to set.
1008
563
  */
1009
564
  setToolSettings(settings: InputToolSettings): void;
1010
565
  /**
1011
- * Gets the settings for the current tool.
566
+ * Gets the settings for the chosen tool
1012
567
  *
1013
- * @returns The settings for the current tool.
568
+ * @example
569
+ * ```typescript
570
+ * const settings = await felt.getToolSettings("marker");
571
+ * ```
572
+ *
573
+ * @returns The settings for the chosen tool.
1014
574
  */
1015
575
  getToolSettings<T extends ConfigurableToolType>(tool: T): Promise<ToolSettingsMap[T]>;
1016
576
  /**
1017
577
  * Listens for changes to the settings on all tools.
1018
578
  *
579
+ * @example
580
+ * ```typescript
581
+ * const unsubscribe = felt.onToolSettingsChange({
582
+ * handler: settings => console.log(settings),
583
+ * });
584
+ *
585
+ * // later on...
586
+ * unsubscribe();
587
+ * ```
1019
588
  * @returns A function to unsubscribe from the listener
1020
589
  */
1021
590
  onToolSettingsChange(args: {
@@ -1174,6 +743,21 @@ interface UiController {
1174
743
  /**
1175
744
  * Updates the UI controls on the embedded map.
1176
745
  *
746
+ * @example
747
+ * ```typescript
748
+ * // Show some UI controls
749
+ * await felt.updateUiControls({
750
+ * showLegend: true,
751
+ * fullScreenButton: true,
752
+ * });
753
+ *
754
+ * // Disable some UI options
755
+ * await felt.updateUiControls({
756
+ * cooperativeGestures: false,
757
+ * geolocation: false,
758
+ * });
759
+ * ```
760
+ *
1177
761
  * @param controls - The controls to update.
1178
762
  */
1179
763
  updateUiControls(controls: UiControlsOptions): void;
@@ -1187,6 +771,15 @@ interface UiController {
1187
771
  *
1188
772
  * This does not affect selection. That means that selectable features and elements
1189
773
  * will still be selected when clicked.
774
+ *
775
+ * @example
776
+ * ```typescript
777
+ * // Disable UI when hovering or selecting features
778
+ * await felt.setOnMapInteractionsUi({
779
+ * featureSelectPanel: false,
780
+ * featureHoverPanel: false,
781
+ * });
782
+ * ```
1190
783
  */
1191
784
  setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void;
1192
785
  /**
@@ -1239,6 +832,16 @@ interface UiController {
1239
832
  interface ViewportController {
1240
833
  /**
1241
834
  * Gets the current state of the viewport.
835
+ *
836
+ * @example
837
+ * ```typescript
838
+ * // Get current viewport state
839
+ * const viewport = await felt.getViewport();
840
+ * console.log({
841
+ * center: viewport.center,
842
+ * zoom: viewport.zoom,
843
+ * });
844
+ * ```
1242
845
  */
1243
846
  getViewport(): Promise<ViewportState>;
1244
847
  /**
@@ -1255,6 +858,21 @@ interface ViewportController {
1255
858
  setViewport(viewport: SetViewportCenterZoomParams): void;
1256
859
  /**
1257
860
  * Gets the current state of the viewport constraints.
861
+ *
862
+ * @example
863
+ * ```typescript
864
+ * // Get current viewport constraints
865
+ * const constraints = await felt.getViewportConstraints();
866
+ * if (constraints) {
867
+ * console.log({
868
+ * bounds: constraints.bounds,
869
+ * minZoom: constraints.minZoom,
870
+ * maxZoom: constraints.maxZoom
871
+ * });
872
+ * } else {
873
+ * console.log("No viewport constraints set");
874
+ * }
875
+ * ```
1258
876
  */
1259
877
  getViewportConstraints(): Promise<ViewportConstraints | null>;
1260
878
  /**
@@ -1449,17 +1067,17 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1449
1067
  }>;
1450
1068
  zoom: z.ZodNumber;
1451
1069
  }, "strip", z.ZodTypeAny, {
1452
- zoom: number;
1453
1070
  center: {
1454
1071
  latitude: number;
1455
1072
  longitude: number;
1456
1073
  };
1457
- }, {
1458
1074
  zoom: number;
1075
+ }, {
1459
1076
  center: {
1460
1077
  latitude: number;
1461
1078
  longitude: number;
1462
1079
  };
1080
+ zoom: number;
1463
1081
  }>>;
1464
1082
  }, "strip", z.ZodTypeAny, {
1465
1083
  origin?: string | undefined;
@@ -1473,11 +1091,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1473
1091
  scaleBar?: boolean | undefined;
1474
1092
  } | undefined;
1475
1093
  initialViewport?: {
1476
- zoom: number;
1477
1094
  center: {
1478
1095
  latitude: number;
1479
1096
  longitude: number;
1480
1097
  };
1098
+ zoom: number;
1481
1099
  } | undefined;
1482
1100
  }, {
1483
1101
  origin?: string | undefined;
@@ -1491,11 +1109,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1491
1109
  scaleBar?: boolean | undefined;
1492
1110
  } | undefined;
1493
1111
  initialViewport?: {
1494
- zoom: number;
1495
1112
  center: {
1496
1113
  latitude: number;
1497
1114
  longitude: number;
1498
1115
  };
1116
+ zoom: number;
1499
1117
  } | undefined;
1500
1118
  }>;
1501
1119
 
@@ -1538,12 +1156,13 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1538
1156
  */
1539
1157
  declare const Felt: {
1540
1158
  /**
1541
- * Embeds a Felt map into the provided container.
1159
+ * Embeds a Felt map into the provided container, returning a promise that resolves
1160
+ * to a {@link FeltController} object that you can use to control the map.
1542
1161
  *
1543
1162
  * @param container - The container element to embed the map into.
1544
1163
  * @param mapId - The ID of the map to embed.
1545
1164
  * @param options - The options to configure the map.
1546
- * @returns
1165
+ * @returns A promise for a {@link FeltController}.
1547
1166
  */
1548
1167
  embed(container: HTMLElement, mapId: string, options?: FeltEmbedOptions): Promise<FeltController>;
1549
1168
  /**
@@ -1552,7 +1171,7 @@ declare const Felt: {
1552
1171
  * @param feltWindow - The iframe element containing the Felt map.
1553
1172
  * @returns
1554
1173
  */
1555
- connect(feltWindow: Window): Promise<FeltController>;
1174
+ connect(feltWindow: Pick<Window, "postMessage">): Promise<FeltController>;
1556
1175
  };
1557
1176
 
1558
- export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, 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 };
1177
+ export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, GeoJsonGeometry, GetElementGroupsConstraint, GetElementsConstraint, InputToolSettings, type InteractionsController, LayersController, 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 };