@feltmaps/js-sdk 1.5.1 → 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.
@@ -13,6 +13,7 @@ type PromiseOrNot<T> = T | Promise<T>;
13
13
  type zInfer<T extends {
14
14
  shape: ZodRawShape;
15
15
  }> = objectOutputType<T["shape"], ZodTypeAny, "strip">;
16
+ type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
16
17
 
17
18
  /**
18
19
  * Represents a point in world coordinates.
@@ -4146,6 +4147,8 @@ interface ElementGroupChangeCallbackParams {
4146
4147
  *
4147
4148
  * The geometry can be obtained via the {@link FeltController.getGeoJsonFeature}
4148
4149
  * method, which returns a {@link GeoJsonFeature} object.
4150
+ *
4151
+ * @group Features
4149
4152
  */
4150
4153
  interface LayerFeature {
4151
4154
  /**
@@ -4159,7 +4162,7 @@ interface LayerFeature {
4159
4162
  /**
4160
4163
  * The type of geometry of the feature.
4161
4164
  *
4162
- * @remarks Because LayerFeatures are read from tiled features, it's
4165
+ * @remarks Because LayerFeatures can be read from tiled features, it's
4163
4166
  * possible that this `geometryType` won't match the `geometry.type` of the
4164
4167
  * {@link GeoJsonFeature} returned by {@link FeltController.getGeoJsonFeature}.
4165
4168
  *
@@ -4169,6 +4172,14 @@ interface LayerFeature {
4169
4172
  * As a result, you should treat this property as being indicative only.
4170
4173
  */
4171
4174
  geometryType: GeoJsonGeometry["type"] | (string & {});
4175
+ /**
4176
+ * The bounding box of the feature.
4177
+ *
4178
+ * @remarks Because LayerFeatures can be read from tiled features and considering
4179
+ * that feature geometry can go through multiple tiles, it's possible that this
4180
+ * is not the complete bounding box of the feature.
4181
+ */
4182
+ bbox: FeltBoundary | undefined;
4172
4183
  /**
4173
4184
  * The properties of the feature, as a bag of attributes.
4174
4185
  */
@@ -4177,9 +4188,9 @@ interface LayerFeature {
4177
4188
  /**
4178
4189
  * A raster pixel value for a specific layer.
4179
4190
  *
4180
- * @interface
4191
+ * @group Features
4181
4192
  */
4182
- type RasterValue = {
4193
+ interface RasterValue {
4183
4194
  /**
4184
4195
  * The value of the pixel.
4185
4196
  */
@@ -4201,7 +4212,7 @@ type RasterValue = {
4201
4212
  b: number;
4202
4213
  a: number;
4203
4214
  };
4204
- };
4215
+ }
4205
4216
 
4206
4217
  /**
4207
4218
  * This describes the processing status of a layer.
@@ -5190,6 +5201,11 @@ declare const CreateLayersFromGeoJsonSchema: z.ZodObject<{
5190
5201
  Line?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
5191
5202
  } | undefined;
5192
5203
  }>;
5204
+ /**
5205
+ * The parameters for the {@link LayersController.createLayersFromGeoJson} method.
5206
+ *
5207
+ * @group Layers
5208
+ */
5193
5209
  interface CreateLayersFromGeoJsonParams extends Omit<zInfer<typeof CreateLayersFromGeoJsonSchema>, "source" | "geometryStyles"> {
5194
5210
  /**
5195
5211
  * The source of the GeoJSON data.
@@ -5415,6 +5431,18 @@ interface LayerFilters {
5415
5431
  */
5416
5432
  combined: Filters;
5417
5433
  }
5434
+ /**
5435
+ * The common type for filtering data by a spatial boundary.
5436
+ *
5437
+ * This can be either:
5438
+ * - `FeltBoundary`: a [w, s, e, n] bounding box
5439
+ * - `PolygonGeometry`: a GeoJSON Polygon geometry
5440
+ * - `MultiPolygonGeometry`: a GeoJSON MultiPolygon geometry
5441
+ * - `LngLatTuple[]`: a list of coordinates describing a single ring of a polygon
5442
+ *
5443
+ * @group Filters
5444
+ */
5445
+ type GeometryFilter = FeltBoundary | PolygonGeometry | MultiPolygonGeometry | LngLatTuple[];
5418
5446
 
5419
5447
  declare const AggregateMethodSchema: z.ZodEnum<["avg", "max", "min", "sum", "median"]>;
5420
5448
  declare const AggregationConfigSchema: z.ZodObject<{
@@ -5451,6 +5479,8 @@ declare const MutliAggregationConfigSchema: z.ZodObject<{
5451
5479
  }>;
5452
5480
  /**
5453
5481
  * Defines how to aggregate a value across features in a layer.
5482
+ *
5483
+ * @group Stats
5454
5484
  */
5455
5485
  interface AggregationConfig extends zInfer<typeof AggregationConfigSchema> {
5456
5486
  /**
@@ -5460,11 +5490,15 @@ interface AggregationConfig extends zInfer<typeof AggregationConfigSchema> {
5460
5490
  }
5461
5491
  /**
5462
5492
  * The method to use for the aggregation.
5493
+ *
5494
+ * @group Stats
5463
5495
  */
5464
5496
  type AggregationMethod = z.infer<typeof AggregateMethodSchema>;
5465
5497
  /**
5466
5498
  * Defines how to aggregate a value across features in a layer with multiple aggregations
5467
5499
  * returned at once.
5500
+ *
5501
+ * @group Stats
5468
5502
  */
5469
5503
  interface MultiAggregationConfig<T extends AggregationMethod | "count"> extends zInfer<typeof MutliAggregationConfigSchema> {
5470
5504
  methods: T[];
@@ -5476,16 +5510,6 @@ interface MultiAggregationConfig<T extends AggregationMethod | "count"> extends
5476
5510
  */
5477
5511
  attribute?: string;
5478
5512
  }
5479
- /**
5480
- * The common type for filtering data by a spatial boundary.
5481
- *
5482
- * This can be either:
5483
- * - `FeltBoundary`: a [w, s, e, n] bounding box
5484
- * - `PolygonGeometry`: a GeoJSON Polygon geometry
5485
- * - `MultiPolygonGeometry`: a GeoJSON MultiPolygon geometry
5486
- * - `LngLatTuple[]`: a list of coordinates describing a single ring of a polygon
5487
- */
5488
- type GeometryFilter = FeltBoundary | PolygonGeometry | MultiPolygonGeometry | LngLatTuple[];
5489
5513
  declare const ValueConfigurationSchema: z.ZodObject<{
5490
5514
  boundary: z.ZodOptional<z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{
5491
5515
  type: z.ZodLiteral<"Polygon">;
@@ -5557,6 +5581,8 @@ declare const ValueConfigurationSchema: z.ZodObject<{
5557
5581
  * and `filters` properties.
5558
5582
  *
5559
5583
  * It can also be used to specify how to aggregate the values via the `aggregation` property.
5584
+ *
5585
+ * @group Stats
5560
5586
  */
5561
5587
  interface ValueConfiguration extends zInfer<typeof ValueConfigurationSchema> {
5562
5588
  /**
@@ -5730,6 +5756,8 @@ declare const GetLayerCategoriesParamsSchema: z.ZodObject<{
5730
5756
  /**
5731
5757
  * The parameters for getting categories from a layer, passed to
5732
5758
  * the {@link LayersController.getCategoryData} method.
5759
+ *
5760
+ * @group Stats
5733
5761
  */
5734
5762
  interface GetLayerCategoriesParams extends zInfer<typeof GetLayerCategoriesParamsSchema> {
5735
5763
  /**
@@ -5777,6 +5805,8 @@ declare const GetLayerCategoriesGroupSchema: z.ZodObject<{
5777
5805
  }>;
5778
5806
  /**
5779
5807
  * A single category from the response from the {@link LayersController.getCategoryData} method.
5808
+ *
5809
+ * @group Stats
5780
5810
  */
5781
5811
  interface GetLayerCategoriesGroup extends zInfer<typeof GetLayerCategoriesGroupSchema> {
5782
5812
  }
@@ -5967,6 +5997,8 @@ declare const GetLayerHistogramParamsSchema: z.ZodObject<{
5967
5997
  /**
5968
5998
  * The params used to request a histogram of values from a layer, passed to
5969
5999
  * the {@link LayersController.getHistogramData} method.
6000
+ *
6001
+ * @group Stats
5970
6002
  */
5971
6003
  interface GetLayerHistogramParams extends zInfer<typeof GetLayerHistogramParamsSchema> {
5972
6004
  /**
@@ -6002,6 +6034,8 @@ declare const GetLayerHistogramBinSchema: z.ZodObject<{
6002
6034
  }>;
6003
6035
  /**
6004
6036
  * One bin from the response from the {@link LayersController.getHistogramData} method.
6037
+ *
6038
+ * @group Stats
6005
6039
  */
6006
6040
  interface GetLayerHistogramBin extends zInfer<typeof GetLayerHistogramBinSchema> {
6007
6041
  }
@@ -6078,6 +6112,8 @@ declare const GetLayerCalculationParamsSchema: z.ZodObject<{
6078
6112
  /**
6079
6113
  * The parameters for calculating a single aggregate value for a layer, passed to
6080
6114
  * the {@link LayersController.getAggregates} method.
6115
+ *
6116
+ * @group Stats
6081
6117
  */
6082
6118
  interface GetLayerCalculationParams<T extends AggregationMethod | "count"> extends z.infer<typeof GetLayerCalculationParamsSchema> {
6083
6119
  /**
@@ -6096,6 +6132,708 @@ interface GetLayerCalculationParams<T extends AggregationMethod | "count"> exten
6096
6132
  aggregation: MultiAggregationConfig<T>;
6097
6133
  }
6098
6134
 
6135
+ /**
6136
+ * The Layers controller allows you to get information about the layers on the
6137
+ * map, and make changes to their visibility.
6138
+ *
6139
+ * Layers can be organised into groups, and their groups can also have their
6140
+ * visibility toggled.
6141
+ *
6142
+ * @group Controller
6143
+ * @public
6144
+ */
6145
+ interface LayersController {
6146
+ /**
6147
+ * Get a single layer from the map by its id.
6148
+ *
6149
+ * @example
6150
+ * ```typescript
6151
+ * const layer = await felt.getLayer("layer-1");
6152
+ * ```
6153
+ * @returns The requested layer.
6154
+ */
6155
+ getLayer(
6156
+ /**
6157
+ * The id of the layer you want to get.
6158
+ */
6159
+ id: string): Promise<Layer | null>;
6160
+ /**
6161
+ * Gets layers from the map, according to the constraints supplied. If no
6162
+ * constraints are supplied, all layers will be returned.
6163
+ *
6164
+ * @remarks The layers in the map, ordered by the order specified in Felt. This is not
6165
+ * necessarily the order that they are drawn in, as Felt draws points above
6166
+ * lines and lines above polygons, for instance.
6167
+ *
6168
+ * @example
6169
+ * ```typescript
6170
+ * const layers = await felt.getLayers();
6171
+ * ```
6172
+ * @returns All layers on the map.
6173
+ */
6174
+ getLayers(
6175
+ /**
6176
+ * The constraints to apply to the layers returned from the map.
6177
+ */
6178
+ constraint?: GetLayersConstraint): Promise<Array<Layer | null>>;
6179
+ /**
6180
+ * Hide or show layers with the given ids.
6181
+ *
6182
+ * @example
6183
+ * ```typescript
6184
+ * felt.setLayerVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
6185
+ * ```
6186
+ */
6187
+ setLayerVisibility(visibility: SetVisibilityRequest): Promise<void>;
6188
+ /**
6189
+ * Set the style for a layer using FSL, the Felt Style Language.
6190
+ *
6191
+ * Changes are only for this session, and not persisted. This is useful to make
6192
+ * temporary changes to a layer's style, such as to highlight a particular layer
6193
+ * or feature.
6194
+ *
6195
+ * See the [FSL documentation](https://developers.felt.com/felt-style-language) for details
6196
+ * on how to read and write styles.
6197
+ *
6198
+ * If the style you set is invalid, you will receive an error explaining the problem
6199
+ * in the rejected promise value.
6200
+ *
6201
+ * @example
6202
+ * ```typescript
6203
+ * // first get the current style
6204
+ * const oldStyle = (await felt.getLayer("layer-1")).style;
6205
+ *
6206
+ * felt.setLayerStyle({ id: "layer-1", style: {
6207
+ * ...oldStyle,
6208
+ * paint: {
6209
+ * ...oldStyle.paint,
6210
+ * color: "red",
6211
+ * },
6212
+ * } });
6213
+ * ```
6214
+ */
6215
+ setLayerStyle(params: {
6216
+ /**
6217
+ * The id of the layer to set the style for.
6218
+ */
6219
+ id: string;
6220
+ /**
6221
+ * The style to set for the layer.
6222
+ */
6223
+ style: object;
6224
+ }): Promise<void>;
6225
+ /**
6226
+ * Hide or show layers with the given ids from the legend.
6227
+ *
6228
+ * @example
6229
+ * ```typescript
6230
+ * felt.setLayerLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
6231
+ * ```
6232
+ */
6233
+ setLayerLegendVisibility(params: SetVisibilityRequest): Promise<void>;
6234
+ /**
6235
+ * Adds a listener for when a layer changes.
6236
+ *
6237
+ * @returns A function to unsubscribe from the listener
6238
+ *
6239
+ * @event
6240
+ * @example
6241
+ * ```typescript
6242
+ * const unsubscribe = felt.onLayerChange({
6243
+ * options: { id: "layer-1" },
6244
+ * handler: ({layer}) => console.log(layer.bounds),
6245
+ * });
6246
+ *
6247
+ * // later on...
6248
+ * unsubscribe();
6249
+ * ```
6250
+ */
6251
+ onLayerChange(args: {
6252
+ options: {
6253
+ /**
6254
+ * The id of the layer to listen for changes to.
6255
+ */
6256
+ id: string;
6257
+ };
6258
+ /**
6259
+ * The handler that is called when the layer changes.
6260
+ */
6261
+ handler: (
6262
+ /**
6263
+ * An object describing the change that occurred.
6264
+ */
6265
+ change: LayerChangeCallbackParams) => void;
6266
+ }): VoidFunction;
6267
+ /**
6268
+ * Adds layers to the map from file or URL sources.
6269
+ *
6270
+ * @remarks This allows you to add temporary layers to the map that don't depend on
6271
+ * any processing by Felt. This is useful for viewing data from external sources or
6272
+ * remote files.
6273
+ *
6274
+ * @returns The layer groups that were created.
6275
+ *
6276
+ * @example
6277
+ * ```typescript
6278
+ * const layerFromFile = await felt.createLayersFromGeoJson({
6279
+ * source: {
6280
+ * type: "geoJsonFile",
6281
+ * file: someFile,
6282
+ * },
6283
+ * name: "Parcels",
6284
+ * });
6285
+ *
6286
+ * const layerFromUrl = await felt.createLayersFromGeoJson({
6287
+ * source: {
6288
+ * sourceType: "geoJsonUrl",
6289
+ * url: "https://example.com/parcels.geojson",
6290
+ * },
6291
+ * name: "Parcels",
6292
+ * ```
6293
+ */
6294
+ createLayersFromGeoJson(params: CreateLayersFromGeoJsonParams): Promise<{
6295
+ /**
6296
+ * The layer group that was created containing the created layers.
6297
+ */
6298
+ layerGroup: LayerGroup;
6299
+ /**
6300
+ * The layers that were created from the source.
6301
+ */
6302
+ layers: Array<Layer>;
6303
+ } | null>;
6304
+ /**
6305
+ * Update a layer by passing a subset of the layer's properties.
6306
+ *
6307
+ * Note that not all properties can be updated, so check the {@link UpdateLayerParams}
6308
+ * type to see which properties can be updated.
6309
+ *
6310
+ * @example
6311
+ * ```typescript
6312
+ * await felt.updateLayer({
6313
+ * id: "layer-1",
6314
+ * name: "My Layer",
6315
+ * caption: "A description of the layer",
6316
+ * });
6317
+ * ```
6318
+ */
6319
+ updateLayer(params: UpdateLayerParams): Promise<Layer>;
6320
+ /**
6321
+ * Delete a layer from the map by its id.
6322
+ *
6323
+ * @remarks This only works for layers created via the SDK `createLayersFromGeoJson` method, not layers added via the Felt UI.
6324
+ *
6325
+ * @example
6326
+ * ```typescript
6327
+ * await felt.deleteLayer("layer-1");
6328
+ * ```
6329
+ */
6330
+ deleteLayer(id: string): Promise<void>;
6331
+ /**
6332
+ * Get a layer group from the map by its id.
6333
+ *
6334
+ * @example
6335
+ * ```typescript
6336
+ * const layerGroup = await felt.getLayerGroup("layer-group-1");
6337
+ * ```
6338
+ * @returns The requested layer group.
6339
+ */
6340
+ getLayerGroup(id: string): Promise<LayerGroup | null>;
6341
+ /**
6342
+ * Gets layer groups from the map, according to the constraints supplied. If no
6343
+ * constraints are supplied, all layer groups will be returned in rendering order.
6344
+ *
6345
+ * @example
6346
+ * ```typescript
6347
+ * const layerGroups = await felt.getLayerGroups({ ids: ["layer-group-1", "layer-group-2"] });
6348
+ * ```
6349
+ * @returns The requested layer groups.
6350
+ */
6351
+ getLayerGroups(
6352
+ /**
6353
+ * The constraints to apply to the layer groups returned from the map.
6354
+ */
6355
+ constraint?: GetLayerGroupsConstraint): Promise<Array<LayerGroup | null>>;
6356
+ /**
6357
+ * Hide or show layer groups with the given ids.
6358
+ *
6359
+ * @example
6360
+ * ```typescript
6361
+ * felt.setLayerGroupVisibility({ show: ["layer-group-1", "layer-group-2"], hide: ["layer-group-3"] });
6362
+ * ```
6363
+ */
6364
+ setLayerGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
6365
+ /**
6366
+ * Hide or show layer groups with the given ids from the legend.
6367
+ *
6368
+ * @example
6369
+ * ```typescript
6370
+ * felt.setLayerGroupLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
6371
+ * ```
6372
+ */
6373
+ setLayerGroupLegendVisibility(params: SetVisibilityRequest): Promise<void>;
6374
+ /**
6375
+ * Adds a listener for when a layer group changes.
6376
+ *
6377
+ * @returns A function to unsubscribe from the listener
6378
+ *
6379
+ * @event
6380
+ * @example
6381
+ * ```typescript
6382
+ * const unsubscribe = felt.onLayerGroupChange({
6383
+ * options: { id: "layer-group-1" },
6384
+ * handler: ({layerGroup}) => console.log(layerGroup.id),
6385
+ * });
6386
+ *
6387
+ * // later on...
6388
+ * unsubscribe();
6389
+ * ```
6390
+ */
6391
+ onLayerGroupChange(args: {
6392
+ options: {
6393
+ id: string;
6394
+ };
6395
+ handler: (change: LayerGroupChangeCallbackParams) => void;
6396
+ }): VoidFunction;
6397
+ /**
6398
+ * Allows you to get the state of a single legend item.
6399
+ *
6400
+ * @example
6401
+ * ```typescript
6402
+ * const legendItem = await felt.getLegendItem({
6403
+ * id: "legend-item-1",
6404
+ * layerId: "layer-1",
6405
+ * })
6406
+ * ```
6407
+ */
6408
+ getLegendItem(id: LegendItemIdentifier): Promise<LegendItem | null>;
6409
+ /**
6410
+ * Allows you to obtain the state of several legend items, by passing in
6411
+ * constraints describing which legend items you want.
6412
+ *
6413
+ * If you do not pass any constraints, you will receive all legend items.
6414
+ *
6415
+ * @example
6416
+ * ```typescript
6417
+ * const legendItems = await felt.getLegendItems({layerId: "layer-1"});
6418
+ * ```
6419
+ */
6420
+ getLegendItems(constraint?: LegendItemsConstraint): Promise<Array<LegendItem | null>>;
6421
+ /**
6422
+ * Hide or show legend items with the given identifiers.
6423
+ *
6424
+ * @example
6425
+ * ```typescript
6426
+ * felt.setLegendItemVisibility({
6427
+ * show: [{layerId: "layer-group-1", id: "item-1-0"}],
6428
+ * hide: [{layerId: "layer-group-2", id: "item-2-0"}],
6429
+ * })
6430
+ * ```
6431
+ */
6432
+ setLegendItemVisibility(visibility: {
6433
+ show?: Array<LegendItemIdentifier>;
6434
+ hide?: Array<LegendItemIdentifier>;
6435
+ }): Promise<void>;
6436
+ /**
6437
+ * Adds a listener for when a legend item changes.
6438
+ *
6439
+ * @returns A function to unsubscribe from the listener
6440
+ *
6441
+ * @event
6442
+ * @example
6443
+ * ```typescript
6444
+ * const unsubscribe = felt.onLegendItemChange({
6445
+ * options: { layerId: "layer-1", id: "item-1-0" },
6446
+ * handler: ({legendItem}) => console.log(legendItem.visible),
6447
+ * });
6448
+ *
6449
+ * // later on...
6450
+ * unsubscribe();
6451
+ * ```
6452
+ */
6453
+ onLegendItemChange(args: {
6454
+ options: LegendItemIdentifier;
6455
+ handler: (change: LegendItemChangeCallbackParams) => void;
6456
+ }): VoidFunction;
6457
+ /**
6458
+ * Get the filters for a layer.
6459
+ *
6460
+ * @remarks
6461
+ * The return type gives you the filters split up into the various sources
6462
+ * that make up the overall filters for a layer.
6463
+ *
6464
+ * @example
6465
+ * ```typescript
6466
+ * const filters = await felt.getLayerFilters("layer-1");
6467
+ * console.log(filters.combined, filters.style, filters.ephemeral, filters.components);
6468
+ * ```
6469
+ */
6470
+ getLayerFilters(layerId: string): Promise<LayerFilters | null>;
6471
+ /**
6472
+ * Sets the **ephemeral** filters for a layer.
6473
+ *
6474
+ * @example
6475
+ * ```typescript
6476
+ * await felt.setLayerFilters({
6477
+ * layerId: "layer-1",
6478
+ * filters: ["AREA", "gt", 30_000],
6479
+ * });
6480
+ * ```
6481
+ */
6482
+ setLayerFilters(params: {
6483
+ /**
6484
+ * The layer that you want to set the filters for.
6485
+ */
6486
+ layerId: string;
6487
+ /**
6488
+ * The filters to set for the layer. This will replace any ephemeral filters
6489
+ * that are currently set for the layer.
6490
+ */
6491
+ filters: Filters;
6492
+ /**
6493
+ * A note to display on the layer legend when this filter is applied. When the
6494
+ * note is shown, a reset button will also be shown, allowing the user to clear
6495
+ * the filter.
6496
+ */
6497
+ note?: string;
6498
+ }): Promise<void>;
6499
+ /**
6500
+ * Adds a listener for when a layer's filters change.
6501
+ *
6502
+ * @returns A function to unsubscribe from the listener
6503
+ *
6504
+ * @remarks
6505
+ * This event fires whenever any type of filter changes on the layer, including
6506
+ * ephemeral filters set via the SDK, style-based filters, or filters set through
6507
+ * the Felt UI via Components.
6508
+ *
6509
+ * @event
6510
+ * @example
6511
+ * ```typescript
6512
+ * const unsubscribe = felt.onLayerFiltersChange({
6513
+ * options: { layerId: "layer-1" },
6514
+ * handler: ({combined, ephemeral, style, components}) => {
6515
+ * console.log("Layer filters updated:", {
6516
+ * combined, // All filters combined
6517
+ * ephemeral, // Filters set via SDK
6518
+ * style, // Filters from layer style
6519
+ * components // Filters from UI components
6520
+ * });
6521
+ * },
6522
+ * });
6523
+ *
6524
+ * // later on...
6525
+ * unsubscribe();
6526
+ * ```
6527
+ */
6528
+ onLayerFiltersChange(params: {
6529
+ options: {
6530
+ layerId: string;
6531
+ };
6532
+ handler: (change: LayerFilters) => void;
6533
+ }): VoidFunction;
6534
+ /**
6535
+ * Get the features that are currently **rendered** on the map in the viewport.
6536
+ *
6537
+ * Note that this is explicitly about the features that are rendered, which isn't
6538
+ * necessarily a complete list of all the features in the viewport. This is because
6539
+ * of the way features are tiled: at low zoom levels or high feature densities, many
6540
+ * features are omitted from what is rendered on the screen.
6541
+ *
6542
+ * @example
6543
+ * ```typescript
6544
+ * const features = await felt.getRenderedFeatures();
6545
+ * ```
6546
+ */
6547
+ getRenderedFeatures(
6548
+ /**
6549
+ * The constraints to apply to the features returned from the map.
6550
+ */
6551
+ params?: GetRenderedFeaturesConstraint): Promise<Array<LayerFeature>>;
6552
+ /**
6553
+ * Get a feature from the map by its ID and layer ID.
6554
+ *
6555
+ * The response is a {@link LayerFeature} object, which does not include the
6556
+ * geometry of the feature.
6557
+ *
6558
+ * You may want to use this when you don't need the geometry of a feature,
6559
+ * but you know the ID of the feature you need.
6560
+ *
6561
+ * @example
6562
+ * ```typescript
6563
+ * const feature = await felt.getFeature({ layerId: "layer-1", id: 123 });
6564
+ * ```
6565
+ */
6566
+ getFeature(params: {
6567
+ id: string | number;
6568
+ layerId: string;
6569
+ }): Promise<LayerFeature | null>;
6570
+ /**
6571
+ * Get a list of layer features.
6572
+ *
6573
+ * @remarks This list is paginated in sets of 20 features for each page. In order to paginate
6574
+ * between pages, the response includes `previousPage` and `nextPage` that are tokens
6575
+ * that should be sent in the `pagination` params for requesting sibling pages.
6576
+ *
6577
+ * Text search is case-insensitive and looks for matches across all feature properties.
6578
+ *
6579
+ * @returns
6580
+ * The response is an object which contains:
6581
+ * - `features`: list of {@link LayerFeature} objects, which does not include
6582
+ * the geometry of the feature but it does include its bounding box.
6583
+ * - `count`: the total number of features that match the query.
6584
+ * - `previousPage` & `nextPage`: The tokens to pass in the `pagination` param
6585
+ * to navigate between pages.
6586
+ *
6587
+ * @example
6588
+ * ```typescript
6589
+ * const page1Response = await felt.getFeatures({
6590
+ * layerId: "layer-1",
6591
+ * search: "abc123",
6592
+ * pagination: undefined,
6593
+ * });
6594
+ *
6595
+ * // Note that the search term here matches the one for the first page.
6596
+ * if (page1Response.nextPage) {
6597
+ * const page2Response = await felt.getFeatures({
6598
+ * layerId: "layer-1",
6599
+ * search: "abc123",
6600
+ * pagination: page1Response.nextPage,
6601
+ * });
6602
+ * }
6603
+ * ```
6604
+ */
6605
+ getFeatures(params: {
6606
+ /**
6607
+ * The ID of the layer to get features from.
6608
+ */
6609
+ layerId: string;
6610
+ /**
6611
+ * Filters to be applied. These filters will merge with layer's own filters.
6612
+ */
6613
+ filters?: Filters;
6614
+ /**
6615
+ * Attribute to sort by.
6616
+ */
6617
+ sorting?: SortConfig;
6618
+ /**
6619
+ * The spatial boundary to be applied.
6620
+ */
6621
+ boundary?: GeometryFilter;
6622
+ /**
6623
+ * Search term to search by.
6624
+ *
6625
+ * Search is case-insensitive and looks for matches across all feature properties.
6626
+ */
6627
+ search?: string;
6628
+ /**
6629
+ * Pagination token. It comes from either the `previousPage` or `nextPage`
6630
+ * properties of the previous response.
6631
+ */
6632
+ pagination?: string | null;
6633
+ }): Promise<{
6634
+ /**
6635
+ * The list of features returned from the query.
6636
+ */
6637
+ features: LayerFeature[];
6638
+ /**
6639
+ * The total number of features that match the query.
6640
+ */
6641
+ count: number;
6642
+ /**
6643
+ * The pagination token to get the previous page of features.
6644
+ */
6645
+ previousPage: string | null;
6646
+ /**
6647
+ * The pagination token to get the next page of features.
6648
+ */
6649
+ nextPage: string | null;
6650
+ }>;
6651
+ /**
6652
+ * Get a feature in GeoJSON format from the map by its ID and layer ID.
6653
+ *
6654
+ * The response is a GeoJSON Feature object with the complete geometry of the
6655
+ * feature. Note that for some _very_ large geometries, the response may take a
6656
+ * long time to return, and may return a very large object.
6657
+ *
6658
+ * @example
6659
+ * ```typescript
6660
+ * const feature = await felt.getGeoJsonFeature({ layerId: "layer-1", id: 123 });
6661
+ * ```
6662
+ */
6663
+ getGeoJsonFeature(params: {
6664
+ id: string | number;
6665
+ layerId: string;
6666
+ }): Promise<GeoJsonFeature | null>;
6667
+ /**
6668
+ * Gets values from a layer grouped by a given attribute.
6669
+ *
6670
+ * @remarks
6671
+ * Groups features in your layer by unique values in the specified attribute and calculates
6672
+ * a value for each group. By default, this value is the count of features in each group.
6673
+ *
6674
+ * You can apply filters in two ways:
6675
+ * 1. At the top level (using `boundary` and `filters`), which affects both what categories
6676
+ * are included and how values are calculated
6677
+ * 2. In the `values` configuration, which only affects the values but keeps all categories
6678
+ *
6679
+ * This two-level filtering is particularly useful when you want to compare subsets of data
6680
+ * while maintaining consistent categories. For example, you might want to show the distribution
6681
+ * of all building types in a city, but only count buildings built after 2000 in each category.
6682
+ *
6683
+ * @example
6684
+ * ```typescript
6685
+ * // Basic grouping: Count of buildings by type
6686
+ * const buildingsByType = await felt.getCategoryData({
6687
+ * layerId: "buildings",
6688
+ * attribute: "type"
6689
+ * });
6690
+ *
6691
+ * // Filtered grouping: Only count buildings in downtown
6692
+ * const downtownBuildingsByType = await felt.getCategoryData({
6693
+ * layerId: "buildings",
6694
+ * attribute: "type",
6695
+ * boundary: [-122.43, 47.60, -122.33, 47.62] // downtown boundary
6696
+ * });
6697
+ *
6698
+ * // Advanced: Show all building types, but only sum floor area of recent buildings
6699
+ * const recentBuildingAreaByType = await felt.getCategoryData({
6700
+ * layerId: "buildings",
6701
+ * attribute: "type",
6702
+ * values: {
6703
+ * filters: ["year_built", "gte", 2000],
6704
+ * aggregation: {
6705
+ * method: "sum",
6706
+ * attribute: "floor_area"
6707
+ * }
6708
+ * }
6709
+ * });
6710
+ *
6711
+ * // Compare residential density across neighborhoods while only counting recent buildings
6712
+ * const newBuildingDensityByNeighborhood = await felt.getCategoryData({
6713
+ * layerId: "buildings",
6714
+ * attribute: "neighborhood",
6715
+ * values: {
6716
+ * filters: ["year_built", "gte", 2000],
6717
+ * aggregation: {
6718
+ * method: "avg",
6719
+ * attribute: "units_per_acre"
6720
+ * }
6721
+ * }
6722
+ * });
6723
+ * ```
6724
+ */
6725
+ getCategoryData(params: GetLayerCategoriesParams): Promise<Array<GetLayerCategoriesGroup>>;
6726
+ /**
6727
+ * Gets a histogram of values from a layer for a given attribute.
6728
+ *
6729
+ * @remarks
6730
+ * Creates bins (ranges) for numeric data and counts how many features fall into each bin,
6731
+ * or returns aggregated values for each bin.
6732
+ *
6733
+ * You can control how the bins are created using the `steps` parameter, choosing from
6734
+ * several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing
6735
+ * in the step values directly if you know how you want to bin the data.
6736
+ *
6737
+ * Like getCategoryData, you can apply filters in two ways:
6738
+ * 1. At the top level (using `boundary` and `filters`), which affects both how the bins
6739
+ * are calculated and what features are counted in each bin
6740
+ * 2. In the `values` configuration, which only affects what gets counted but keeps the
6741
+ * bin ranges the same
6742
+ *
6743
+ * This is particularly useful when you want to compare distributions while keeping
6744
+ * consistent bin ranges. For example, you might want to compare the distribution of
6745
+ * building heights in different years while using the same height ranges.
6746
+ *
6747
+ * @example
6748
+ * ```typescript
6749
+ * // Basic histogram: Building heights in 5 natural break bins
6750
+ * const buildingHeights = await felt.getHistogramData({
6751
+ * layerId: "buildings",
6752
+ * attribute: "height",
6753
+ * steps: { type: "jenks", count: 5 }
6754
+ * });
6755
+ *
6756
+ * // Compare old vs new buildings using the same height ranges
6757
+ * const oldBuildingHeights = await felt.getHistogramData({
6758
+ * layerId: "buildings",
6759
+ * attribute: "height",
6760
+ * steps: [0, 20, 50, 100, 200, 500],
6761
+ * values: {
6762
+ * filters: ["year_built", "lt", 1950]
6763
+ * }
6764
+ * });
6765
+ *
6766
+ * const newBuildingHeights = await felt.getHistogramData({
6767
+ * layerId: "buildings",
6768
+ * attribute: "height",
6769
+ * steps: [0, 20, 50, 100, 200, 500], // Same ranges as above
6770
+ * values: {
6771
+ * filters: ["year_built", "gte", 1950]
6772
+ * }
6773
+ * });
6774
+ * ```
6775
+ */
6776
+ getHistogramData(params: GetLayerHistogramParams): Promise<Array<GetLayerHistogramBin>>;
6777
+ /**
6778
+ * Calculates a single aggregate value for a layer based on the provided configuration.
6779
+ *
6780
+ * @remarks
6781
+ * Performs statistical calculations on your data, like counting features or computing
6782
+ * averages, sums, etc. You can focus your calculation on specific areas or subsets
6783
+ * of your data using boundaries and filters.
6784
+ *
6785
+ * When no aggregation is specified, it counts features. When an aggregation is provided,
6786
+ * it performs that calculation (average, sum, etc.) on the specified attribute.
6787
+ *
6788
+ * @example
6789
+ * ```typescript
6790
+ * // Count all residential buildings
6791
+ * const residentialCount = await felt.getAggregates({
6792
+ * layerId: "buildings",
6793
+ * filters: ["type", "eq", "residential"]
6794
+ * });
6795
+ *
6796
+ * // Calculate average home value in a specific neighborhood
6797
+ * const avgHomeValue = await felt.getAggregates({
6798
+ * layerId: "buildings",
6799
+ * boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
6800
+ * aggregation: {
6801
+ * method: "avg",
6802
+ * attribute: "assessed_value"
6803
+ * }
6804
+ * });
6805
+ *
6806
+ * // Find the maximum building height for buildings built after 2000
6807
+ * const maxNewBuildingHeight = await felt.getAggregates({
6808
+ * layerId: "buildings",
6809
+ * filters: ["year_built", "gte", 2000],
6810
+ * aggregation: {
6811
+ * method: "max",
6812
+ * attribute: "height"
6813
+ * }
6814
+ * });
6815
+ * ```
6816
+ */
6817
+ getAggregates<T extends AggregationMethod | "count">(params: GetLayerCalculationParams<T>): Promise<Record<T, number | null>>;
6818
+ /**
6819
+ * Get the schema for a layer.
6820
+ *
6821
+ * @remarks
6822
+ * The schema describes the structure of the data in a layer, including the attributes
6823
+ * that are available on the features in the layer.
6824
+ *
6825
+ * This can be useful to build generic UIs that need to know the structure of the data in
6826
+ * a layer, such as a dropdown to choose an attribute.
6827
+ *
6828
+ * @example
6829
+ * ```typescript
6830
+ * const schema = await felt.getLayerSchema("layer-1");
6831
+ * const attributeIds = schema.attributes.map((attr) => attr.id);
6832
+ * ```
6833
+ */
6834
+ getLayerSchema(layerId: string): Promise<LayerSchema>;
6835
+ }
6836
+
6099
6837
  /**
6100
6838
  * The event object passed to the interaction listeners.
6101
6839
  */
@@ -6654,4 +7392,4 @@ declare const ViewportFitBoundsParamsSchema: z.ZodObject<{
6654
7392
  bounds: [number, number, number, number];
6655
7393
  }>;
6656
7394
 
6657
- export type { HighlighterElementCreate as $, AggregationMethod as A, MapDetails as B, CreateLayersFromGeoJsonParams as C, EntityNode as D, Element as E, Filters as F, GeoJsonGeometry as G, FeatureSelection as H, InputToolSettings as I, ConfigurableToolType as J, ToolSettingsMap as K, Layer as L, MapInteractionEvent as M, ToolSettingsChangeEvent as N, zInfer as O, SortConfig as P, SetViewportCenterZoomParams as Q, ViewportConstraints as R, SetVisibilityRequest as S, ToolType as T, UpdateLayerParams as U, ViewportState as V, ViewportFitBoundsParams as W, ViewportCenterZoom as X, CircleElementCreate as Y, CircleElementRead as Z, CircleElementUpdate as _, GetElementsConstraint as a, MultiPolygonGeometry as a$, HighlighterElementRead as a0, HighlighterElementUpdate as a1, ImageElementCreate as a2, ImageElementRead as a3, ImageElementUpdate as a4, LinkElementRead as a5, MarkerElementCreate as a6, MarkerElementRead as a7, MarkerElementUpdate as a8, NoteElementCreate as a9, LayerSchemaAttribute as aA, LayerSchemaBooleanAttribute as aB, LayerSchemaCommonAttribute as aC, LayerSchemaDateAttribute as aD, LayerSchemaDateTimeAttribute as aE, LayerSchemaNumericAttribute as aF, LayerSchemaTextAttribute as aG, FilterExpression as aH, FilterLogicGate as aI, FilterTernary as aJ, AggregationConfig as aK, GeometryFilter as aL, MultiAggregationConfig as aM, ValueConfiguration as aN, ElementGroupNode as aO, ElementNode as aP, FeatureNode as aQ, LayerGroupNode as aR, LayerNode as aS, FeltBoundary as aT, FeltZoom as aU, GeoJsonProperties as aV, LatLng as aW, LineStringGeometry as aX, LngLatTuple as aY, MultiLineStringGeometry as aZ, MultiPointGeometry as a_, NoteElementRead as aa, NoteElementUpdate as ab, PathElementCreate as ac, PathElementRead as ad, PathElementUpdate as ae, PlaceElementCreate as af, PlaceElementRead as ag, PlaceElementUpdate as ah, PolygonElementCreate as ai, PolygonElementRead as aj, PolygonElementUpdate as ak, TextElementCreate as al, TextElementRead as am, TextElementUpdate as an, DataOnlyLayer as ao, FeltTiledVectorSource as ap, GeoJsonDataVectorSource as aq, GeoJsonFileVectorSource as ar, GeoJsonUrlVectorSource as as, LayerCommon as at, LayerProcessingStatus as au, RasterBand as av, RasterLayer as aw, RasterLayerSource as ax, RasterValue as ay, VectorLayer as az, ElementGroup as b, PointGeometry as b0, PolygonGeometry as b1, SortDirection as b2, CircleToolSettings as b3, HighlighterToolSettings as b4, LineToolSettings as b5, MarkerToolSettings as b6, NoteToolSettings as b7, PinToolSettings as b8, PlaceFrame as b9, PlaceSymbol as ba, PolygonToolSettings as bb, RouteToolSettings as bc, TextToolSettings as bd, UnionToIntersection as be, PromiseOrNot as bf, GetElementGroupsConstraint as c, ElementChangeCallbackParams as d, ElementGroupChangeCallbackParams as e, ElementCreate as f, ElementUpdate as g, GetLayersConstraint as h, LayerChangeCallbackParams as i, LayerGroup as j, GetLayerGroupsConstraint as k, LayerGroupChangeCallbackParams as l, LegendItemIdentifier as m, LegendItem as n, LegendItemsConstraint as o, LegendItemChangeCallbackParams as p, LayerFilters as q, GetRenderedFeaturesConstraint as r, LayerFeature as s, GeoJsonFeature as t, GetLayerCategoriesParams as u, GetLayerCategoriesGroup as v, GetLayerHistogramParams as w, GetLayerHistogramBin as x, GetLayerCalculationParams as y, LayerSchema as z };
7395
+ export type { TextElementRead as $, MarkerElementCreate as A, MarkerElementRead as B, ConfigurableToolType as C, MarkerElementUpdate as D, Element as E, FeatureSelection as F, GeoJsonGeometry as G, HighlighterElementCreate as H, InputToolSettings as I, NoteElementRead as J, NoteElementUpdate as K, LayersController as L, MapInteractionEvent as M, NoteElementCreate as N, PathElementRead as O, PathElementCreate as P, PathElementUpdate as Q, PlaceElementCreate as R, SetVisibilityRequest as S, ToolType as T, PlaceElementRead as U, ViewportState as V, PlaceElementUpdate as W, PolygonElementCreate as X, PolygonElementRead as Y, PolygonElementUpdate as Z, TextElementCreate as _, GetElementsConstraint as a, MultiPointGeometry as a$, TextElementUpdate as a0, CreateLayersFromGeoJsonParams as a1, DataOnlyLayer as a2, FeltTiledVectorSource as a3, GeoJsonDataVectorSource as a4, GeoJsonFileVectorSource as a5, GeoJsonUrlVectorSource as a6, GetLayerGroupsConstraint as a7, GetLayersConstraint as a8, GetRenderedFeaturesConstraint as a9, FilterLogicGate as aA, FilterTernary as aB, Filters as aC, GeometryFilter as aD, LayerFilters as aE, AggregationConfig as aF, AggregationMethod as aG, GetLayerCalculationParams as aH, GetLayerCategoriesGroup as aI, GetLayerCategoriesParams as aJ, GetLayerHistogramBin as aK, GetLayerHistogramParams as aL, MultiAggregationConfig as aM, ValueConfiguration as aN, ElementGroupNode as aO, ElementNode as aP, FeatureNode as aQ, LayerGroupNode as aR, LayerNode as aS, FeltBoundary as aT, FeltZoom as aU, GeoJsonFeature as aV, GeoJsonProperties as aW, LatLng as aX, LineStringGeometry as aY, LngLatTuple as aZ, MultiLineStringGeometry as a_, Layer as aa, LayerChangeCallbackParams as ab, LayerCommon as ac, LayerGroup as ad, LayerGroupChangeCallbackParams as ae, LayerProcessingStatus as af, LegendItem as ag, LegendItemChangeCallbackParams as ah, LegendItemIdentifier as ai, LegendItemsConstraint as aj, RasterBand as ak, RasterLayer as al, RasterLayerSource as am, UpdateLayerParams as an, VectorLayer as ao, LayerFeature as ap, RasterValue as aq, LayerSchema as ar, LayerSchemaAttribute as as, LayerSchemaBooleanAttribute as at, LayerSchemaCommonAttribute as au, LayerSchemaDateAttribute as av, LayerSchemaDateTimeAttribute as aw, LayerSchemaNumericAttribute as ax, LayerSchemaTextAttribute as ay, FilterExpression as az, ElementGroup as b, MultiPolygonGeometry as b0, PointGeometry as b1, PolygonGeometry as b2, SortDirection as b3, CircleToolSettings as b4, HighlighterToolSettings as b5, LineToolSettings as b6, MarkerToolSettings as b7, NoteToolSettings as b8, PinToolSettings as b9, PlaceFrame as ba, PlaceSymbol as bb, PolygonToolSettings as bc, RouteToolSettings as bd, TextToolSettings as be, UnwrapPromise as bf, UnionToIntersection as bg, PromiseOrNot as bh, GetElementGroupsConstraint as c, ElementChangeCallbackParams as d, ElementGroupChangeCallbackParams as e, ElementCreate as f, ElementUpdate as g, MapDetails as h, EntityNode as i, ToolSettingsMap as j, ToolSettingsChangeEvent as k, SortConfig as l, SetViewportCenterZoomParams as m, ViewportConstraints as n, ViewportFitBoundsParams as o, ViewportCenterZoom as p, CircleElementCreate as q, CircleElementRead as r, CircleElementUpdate as s, HighlighterElementRead as t, HighlighterElementUpdate as u, ImageElementCreate as v, ImageElementRead as w, ImageElementUpdate as x, LinkElementRead as y, zInfer as z };