@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.
package/dist/client.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var c=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var x=(e,o)=>{for(var n in o)c(e,n,{get:o[n],enumerable:!0})},f=(e,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of b(o))!I.call(e,a)&&a!==n&&c(e,a,{get:()=>o[a],enumerable:!(s=V(o,a))||s.enumerable});return e};var K=e=>f(c({},"__esModule",{value:!0}),e);var O={};x(O,{Felt:()=>S});module.exports=K(O);function r(e,o){return n=>{let s=new MessageChannel,a=n.handler,i="options"in n?n.options:void 0,m=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:i?{eventName:o,id:m,options:i}:{eventName:o,id:m}},"*",[s.port2]),s.port1.onmessage=y=>{u(y)||a(y.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:m},"*")}}}function t(e,o,n){return async s=>{let a=new MessageChannel,i=s&&n?await n(s):s;return e.postMessage({type:o,params:i},"*",[a.port2]),new Promise((m,y)=>{a.port1.onmessage=g=>{u(g)?y(new Error(g.data.__error__)):m(g.data),a.port1.close(),a.port2.close()}})}}function u(e){return e.data&&typeof e.data=="object"&&"__error__"in e.data}var C=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:r(e,"onElementChange"),onElementCreate:r(e,"onElementCreate"),onElementCreateEnd:r(e,"onElementCreateEnd"),onElementDelete:r(e,"onElementDelete"),onElementGroupChange:r(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var L=e=>({onPointerClick:r(e,"onPointerClick"),onPointerMove:r(e,"onPointerMove")});var T=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:r(e,"onLayerChange"),createLayersFromGeoJson:t(e,"createLayersFromGeoJson",h),updateLayer:t(e,"updateLayer",h),deleteLayer:t(e,"deleteLayer"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:r(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:r(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),onLayerFiltersChange:r(e,"onLayerFiltersChange"),getRenderedFeatures:t(e,"getRenderedFeatures"),getFeature:t(e,"getFeature"),getGeoJsonFeature:t(e,"getGeoJsonFeature"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates"),getLayerSchema:t(e,"getLayerSchema")});async function h(e){let{source:o}=e;return o&&o.type==="geoJsonFile"?{...e,source:{type:"geoJsonData",data:JSON.parse(await o.file.text())}}:e}var P=e=>({getMapDetails:t(e,"getMapDetails")});var E=e=>({onSelectionChange:r(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var v=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:r(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:r(e,"onToolSettingsChange")});var M=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi"),showLayerDataTable:t(e,"showLayerDataTable"),hideLayerDataTable:t(e,"hideLayerDataTable")});var F=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:r(e,"onViewportMove"),onViewportMoveEnd:r(e,"onViewportMoveEnd"),onMapIdle:r(e,"onMapIdle")});function G(e){return{iframe:null,...F(e),...M(e),...T(e),...C(e),...E(e),...L(e),...v(e),...P(e)}}var S={embed(e,o,n){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},a=n?.origin??s.origin,i=new URL(`${a}/embed/map/${o}`),m={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},y={...s.uiControls,...n?.uiControls};for(let[p,d]of k(y))d!=null&&i.searchParams.set(m[p],d?"1":"0");if(n?.token&&i.searchParams.set("token",n.token),n?.initialViewport){let p=n.initialViewport;i.searchParams.set("loc",`${p.center.latitude},${p.center.longitude},${p.zoom}z`)}let g=e.tagName==="IFRAME",l=g?e:e.ownerDocument.createElement("iframe");return l.src=i.toString(),g||(l.style.width="100%",l.style.height="100%",l.style.border="none",l.style.margin="0",e.appendChild(l)),l.referrerPolicy="strict-origin-when-cross-origin",new Promise((p,d)=>{l.addEventListener("load",()=>{l.contentWindow==null?d(new Error("Failed to load Felt map")):p(l.contentWindow)},{once:!0})}).then(S.connect).then(p=>(Object.defineProperties(p,{iframe:{value:l,writable:!1,configurable:!1}}),p))},connect(e){let o=G(e);return new Promise((n,s)=>{let a=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(m)},5e3),i=new MessageChannel,m=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[i.port2])},100);i.port1.onmessage=y=>{y.data===!0&&(clearInterval(m),clearTimeout(a),i.port1.close(),i.port2.close(),n(o))}})}},k=Object.entries;0&&(module.exports={Felt});
1
+ "use strict";var c=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var x=(e,o)=>{for(var n in o)c(e,n,{get:o[n],enumerable:!0})},f=(e,o,n,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of b(o))!I.call(e,a)&&a!==n&&c(e,a,{get:()=>o[a],enumerable:!(s=V(o,a))||s.enumerable});return e};var K=e=>f(c({},"__esModule",{value:!0}),e);var O={};x(O,{Felt:()=>S});module.exports=K(O);function r(e,o){return n=>{let s=new MessageChannel,a=n.handler,i="options"in n?n.options:void 0,m=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:i?{eventName:o,id:m,options:i}:{eventName:o,id:m}},"*",[s.port2]),s.port1.onmessage=g=>{u(g)||a(g.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:m},"*")}}}function t(e,o,n){return async s=>{let a=new MessageChannel,i=s&&n?await n(s):s;return e.postMessage({type:o,params:i},"*",[a.port2]),new Promise((m,g)=>{a.port1.onmessage=y=>{u(y)?g(new Error(y.data.__error__)):m(y.data),a.port1.close(),a.port2.close()}})}}function u(e){return e.data&&typeof e.data=="object"&&"__error__"in e.data}var C=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:r(e,"onElementChange"),onElementCreate:r(e,"onElementCreate"),onElementCreateEnd:r(e,"onElementCreateEnd"),onElementDelete:r(e,"onElementDelete"),onElementGroupChange:r(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var L=e=>({onPointerClick:r(e,"onPointerClick"),onPointerMove:r(e,"onPointerMove")});var T=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:r(e,"onLayerChange"),createLayersFromGeoJson:t(e,"createLayersFromGeoJson",h),updateLayer:t(e,"updateLayer",h),deleteLayer:t(e,"deleteLayer"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:r(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:r(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),onLayerFiltersChange:r(e,"onLayerFiltersChange"),getRenderedFeatures:t(e,"getRenderedFeatures"),getFeature:t(e,"getFeature"),getFeatures:t(e,"getFeatures"),getGeoJsonFeature:t(e,"getGeoJsonFeature"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates"),getLayerSchema:t(e,"getLayerSchema")});async function h(e){let{source:o}=e;return o&&o.type==="geoJsonFile"?{...e,source:{type:"geoJsonData",data:JSON.parse(await o.file.text())}}:e}var P=e=>({getMapDetails:t(e,"getMapDetails")});var E=e=>({onSelectionChange:r(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var v=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:r(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:r(e,"onToolSettingsChange")});var F=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi"),showLayerDataTable:t(e,"showLayerDataTable"),hideLayerDataTable:t(e,"hideLayerDataTable")});var M=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:r(e,"onViewportMove"),onViewportMoveEnd:r(e,"onViewportMoveEnd"),onMapIdle:r(e,"onMapIdle")});function G(e){return{iframe:null,...M(e),...F(e),...T(e),...C(e),...E(e),...L(e),...v(e),...P(e)}}var S={embed(e,o,n){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},a=n?.origin??s.origin,i=new URL(`${a}/embed/map/${o}`),m={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},g={...s.uiControls,...n?.uiControls};for(let[p,d]of k(g))d!=null&&i.searchParams.set(m[p],d?"1":"0");if(n?.token&&i.searchParams.set("token",n.token),n?.initialViewport){let p=n.initialViewport;i.searchParams.set("loc",`${p.center.latitude},${p.center.longitude},${p.zoom}z`)}let y=e.tagName==="IFRAME",l=y?e:e.ownerDocument.createElement("iframe");return l.src=i.toString(),y||(l.style.width="100%",l.style.height="100%",l.style.border="none",l.style.margin="0",e.appendChild(l)),l.referrerPolicy="strict-origin-when-cross-origin",new Promise((p,d)=>{l.addEventListener("load",()=>{l.contentWindow==null?d(new Error("Failed to load Felt map")):p(l.contentWindow)},{once:!0})}).then(S.connect).then(p=>(Object.defineProperties(p,{iframe:{value:l,writable:!1,configurable:!1}}),p))},connect(e){let o=G(e);return new Promise((n,s)=>{let a=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(m)},5e3),i=new MessageChannel,m=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[i.port2])},100);i.port1.onmessage=g=>{g.data===!0&&(clearInterval(m),clearTimeout(a),i.port1.close(),i.port2.close(),n(o))}})}},k=Object.entries;0&&(module.exports={Felt});
package/dist/client.d.cts CHANGED
@@ -1,5 +1,5 @@
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, U as UpdateLayerParams, 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, W as ViewportFitBoundsParams, X as ViewportCenterZoom } from './types-CnYUajGG.cjs';
2
- export { aK as AggregationConfig, Y as CircleElementCreate, Z as CircleElementRead, _ as CircleElementUpdate, b3 as CircleToolSettings, ao as DataOnlyLayer, aO as ElementGroupNode, aP as ElementNode, aQ as FeatureNode, aT as FeltBoundary, ap as FeltTiledVectorSource, aU as FeltZoom, aH as FilterExpression, aI as FilterLogicGate, aJ as FilterTernary, aq as GeoJsonDataVectorSource, ar as GeoJsonFileVectorSource, aV as GeoJsonProperties, as as GeoJsonUrlVectorSource, aL as GeometryFilter, $ as HighlighterElementCreate, a0 as HighlighterElementRead, a1 as HighlighterElementUpdate, b4 as HighlighterToolSettings, a2 as ImageElementCreate, a3 as ImageElementRead, a4 as ImageElementUpdate, aW as LatLng, at as LayerCommon, aR as LayerGroupNode, aS as LayerNode, au as LayerProcessingStatus, aA as LayerSchemaAttribute, aB as LayerSchemaBooleanAttribute, aC as LayerSchemaCommonAttribute, aD as LayerSchemaDateAttribute, aE as LayerSchemaDateTimeAttribute, aF as LayerSchemaNumericAttribute, aG as LayerSchemaTextAttribute, aX as LineStringGeometry, b5 as LineToolSettings, a5 as LinkElementRead, aY as LngLatTuple, a6 as MarkerElementCreate, a7 as MarkerElementRead, a8 as MarkerElementUpdate, b6 as MarkerToolSettings, aM as MultiAggregationConfig, aZ as MultiLineStringGeometry, a_ as MultiPointGeometry, a$ as MultiPolygonGeometry, a9 as NoteElementCreate, aa as NoteElementRead, ab as NoteElementUpdate, b7 as NoteToolSettings, ac as PathElementCreate, ad as PathElementRead, ae as PathElementUpdate, b8 as PinToolSettings, af as PlaceElementCreate, ag as PlaceElementRead, ah as PlaceElementUpdate, b9 as PlaceFrame, ba as PlaceSymbol, b0 as PointGeometry, ai as PolygonElementCreate, aj as PolygonElementRead, ak as PolygonElementUpdate, b1 as PolygonGeometry, bb as PolygonToolSettings, av as RasterBand, aw as RasterLayer, ax as RasterLayerSource, ay as RasterValue, bc as RouteToolSettings, b2 as SortDirection, al as TextElementCreate, am as TextElementRead, an as TextElementUpdate, bd as TextToolSettings, aN as ValueConfiguration, az as VectorLayer } from './types-CnYUajGG.cjs';
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.cjs';
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.cjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -311,627 +311,6 @@ interface ElementsController {
311
311
  deleteElement(id: string): Promise<void>;
312
312
  }
313
313
 
314
- /**
315
- * The Layers controller allows you to get information about the layers on the
316
- * map, and make changes to their visibility.
317
- *
318
- * Layers can be organised into groups, and their groups can also have their
319
- * visibility toggled.
320
- *
321
- * @group Controller
322
- * @public
323
- */
324
- interface LayersController {
325
- /**
326
- * Get a single layer from the map by its id.
327
- *
328
- * @example
329
- * ```typescript
330
- * const layer = await felt.getLayer("layer-1");
331
- * ```
332
- * @returns The requested layer.
333
- */
334
- getLayer(
335
- /**
336
- * The id of the layer you want to get.
337
- */
338
- id: string): Promise<Layer | null>;
339
- /**
340
- * Gets layers from the map, according to the constraints supplied. If no
341
- * constraints are supplied, all layers will be returned.
342
- *
343
- * @remarks The layers in the map, ordered by the order specified in Felt. This is not
344
- * necessarily the order that they are drawn in, as Felt draws points above
345
- * lines and lines above polygons, for instance.
346
- *
347
- * @example
348
- * ```typescript
349
- * const layers = await felt.getLayers();
350
- * ```
351
- * @returns All layers on the map.
352
- */
353
- getLayers(
354
- /**
355
- * The constraints to apply to the layers returned from the map.
356
- */
357
- constraint?: GetLayersConstraint): Promise<Array<Layer | null>>;
358
- /**
359
- * Hide or show layers with the given ids.
360
- *
361
- * @example
362
- * ```typescript
363
- * felt.setLayerVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
364
- * ```
365
- */
366
- setLayerVisibility(visibility: SetVisibilityRequest): Promise<void>;
367
- /**
368
- * Set the style for a layer using FSL, the Felt Style Language.
369
- *
370
- * Changes are only for this session, and not persisted. This is useful to make
371
- * temporary changes to a layer's style, such as to highlight a particular layer
372
- * or feature.
373
- *
374
- * See the [FSL documentation](https://developers.felt.com/felt-style-language) for details
375
- * on how to read and write styles.
376
- *
377
- * If the style you set is invalid, you will receive an error explaining the problem
378
- * in the rejected promise value.
379
- *
380
- * @example
381
- * ```typescript
382
- * // first get the current style
383
- * const oldStyle = (await felt.getLayer("layer-1")).style;
384
- *
385
- * felt.setLayerStyle({ id: "layer-1", style: {
386
- * ...oldStyle,
387
- * paint: {
388
- * ...oldStyle.paint,
389
- * color: "red",
390
- * },
391
- * } });
392
- * ```
393
- */
394
- setLayerStyle(params: {
395
- /**
396
- * The id of the layer to set the style for.
397
- */
398
- id: string;
399
- /**
400
- * The style to set for the layer.
401
- */
402
- style: object;
403
- }): Promise<void>;
404
- /**
405
- * Hide or show layers with the given ids from the legend.
406
- *
407
- * @example
408
- * ```typescript
409
- * felt.setLayerLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
410
- * ```
411
- */
412
- setLayerLegendVisibility(params: SetVisibilityRequest): Promise<void>;
413
- /**
414
- * Adds a listener for when a layer changes.
415
- *
416
- * @returns A function to unsubscribe from the listener
417
- *
418
- * @event
419
- * @example
420
- * ```typescript
421
- * const unsubscribe = felt.onLayerChange({
422
- * options: { id: "layer-1" },
423
- * handler: ({layer}) => console.log(layer.bounds),
424
- * });
425
- *
426
- * // later on...
427
- * unsubscribe();
428
- * ```
429
- */
430
- onLayerChange(args: {
431
- options: {
432
- /**
433
- * The id of the layer to listen for changes to.
434
- */
435
- id: string;
436
- };
437
- /**
438
- * The handler that is called when the layer changes.
439
- */
440
- handler: (
441
- /**
442
- * An object describing the change that occurred.
443
- */
444
- change: LayerChangeCallbackParams) => void;
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
- * Update a layer by passing a subset of the layer's properties.
485
- *
486
- * Note that not all properties can be updated, so check the {@link UpdateLayerParams}
487
- * type to see which properties can be updated.
488
- *
489
- * @example
490
- * ```typescript
491
- * await felt.updateLayer({
492
- * id: "layer-1",
493
- * name: "My Layer",
494
- * caption: "A description of the layer",
495
- * });
496
- * ```
497
- */
498
- updateLayer(params: UpdateLayerParams): Promise<Layer>;
499
- /**
500
- * Delete a layer from the map by its id.
501
- *
502
- * @remarks This only works for layers created via the SDK `createLayersFromGeoJson` method, not layers added via the Felt UI.
503
- *
504
- * @example
505
- * ```typescript
506
- * await felt.deleteLayer("layer-1");
507
- * ```
508
- */
509
- deleteLayer(id: string): Promise<void>;
510
- /**
511
- * Get a layer group from the map by its id.
512
- *
513
- * @example
514
- * ```typescript
515
- * const layerGroup = await felt.getLayerGroup("layer-group-1");
516
- * ```
517
- * @returns The requested layer group.
518
- */
519
- getLayerGroup(id: string): Promise<LayerGroup | null>;
520
- /**
521
- * Gets layer groups from the map, according to the constraints supplied. If no
522
- * constraints are supplied, all layer groups will be returned in rendering order.
523
- *
524
- * @example
525
- * ```typescript
526
- * const layerGroups = await felt.getLayerGroups({ ids: ["layer-group-1", "layer-group-2"] });
527
- * ```
528
- * @returns The requested layer groups.
529
- */
530
- getLayerGroups(
531
- /**
532
- * The constraints to apply to the layer groups returned from the map.
533
- */
534
- constraint?: GetLayerGroupsConstraint): Promise<Array<LayerGroup | null>>;
535
- /**
536
- * Hide or show layer groups with the given ids.
537
- *
538
- * @example
539
- * ```typescript
540
- * felt.setLayerGroupVisibility({ show: ["layer-group-1", "layer-group-2"], hide: ["layer-group-3"] });
541
- * ```
542
- */
543
- setLayerGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
544
- /**
545
- * Hide or show layer groups with the given ids from the legend.
546
- *
547
- * @example
548
- * ```typescript
549
- * felt.setLayerGroupLegendVisibility({ show: ["layer-1", "layer-2"], hide: ["layer-3"] });
550
- * ```
551
- */
552
- setLayerGroupLegendVisibility(params: SetVisibilityRequest): Promise<void>;
553
- /**
554
- * Adds a listener for when a layer group changes.
555
- *
556
- * @returns A function to unsubscribe from the listener
557
- *
558
- * @event
559
- * @example
560
- * ```typescript
561
- * const unsubscribe = felt.onLayerGroupChange({
562
- * options: { id: "layer-group-1" },
563
- * handler: ({layerGroup}) => console.log(layerGroup.id),
564
- * });
565
- *
566
- * // later on...
567
- * unsubscribe();
568
- * ```
569
- */
570
- onLayerGroupChange(args: {
571
- options: {
572
- id: string;
573
- };
574
- handler: (change: LayerGroupChangeCallbackParams) => void;
575
- }): VoidFunction;
576
- /**
577
- * Allows you to get the state of a single legend item.
578
- *
579
- * @example
580
- * ```typescript
581
- * const legendItem = await felt.getLegendItem({
582
- * id: "legend-item-1",
583
- * layerId: "layer-1",
584
- * })
585
- * ```
586
- */
587
- getLegendItem(id: LegendItemIdentifier): Promise<LegendItem | null>;
588
- /**
589
- * Allows you to obtain the state of several legend items, by passing in
590
- * constraints describing which legend items you want.
591
- *
592
- * If you do not pass any constraints, you will receive all legend items.
593
- *
594
- * @example
595
- * ```typescript
596
- * const legendItems = await felt.getLegendItems({layerId: "layer-1"});
597
- * ```
598
- */
599
- getLegendItems(constraint?: LegendItemsConstraint): Promise<Array<LegendItem | null>>;
600
- /**
601
- * Hide or show legend items with the given identifiers.
602
- *
603
- * @example
604
- * ```typescript
605
- * felt.setLegendItemVisibility({
606
- * show: [{layerId: "layer-group-1", id: "item-1-0"}],
607
- * hide: [{layerId: "layer-group-2", id: "item-2-0"}],
608
- * })
609
- * ```
610
- */
611
- setLegendItemVisibility(visibility: {
612
- show?: Array<LegendItemIdentifier>;
613
- hide?: Array<LegendItemIdentifier>;
614
- }): Promise<void>;
615
- /**
616
- * Adds a listener for when a legend item changes.
617
- *
618
- * @returns A function to unsubscribe from the listener
619
- *
620
- * @event
621
- * @example
622
- * ```typescript
623
- * const unsubscribe = felt.onLegendItemChange({
624
- * options: { layerId: "layer-1", id: "item-1-0" },
625
- * handler: ({legendItem}) => console.log(legendItem.visible),
626
- * });
627
- *
628
- * // later on...
629
- * unsubscribe();
630
- * ```
631
- */
632
- onLegendItemChange(args: {
633
- options: LegendItemIdentifier;
634
- handler: (change: LegendItemChangeCallbackParams) => void;
635
- }): VoidFunction;
636
- /**
637
- * Get the filters for a layer.
638
- *
639
- * @remarks
640
- * The return type gives you the filters split up into the various sources
641
- * that make up the overall filters for a layer.
642
- *
643
- * @example
644
- * ```typescript
645
- * const filters = await felt.getLayerFilters("layer-1");
646
- * console.log(filters.combined, filters.style, filters.ephemeral, filters.components);
647
- * ```
648
- */
649
- getLayerFilters(layerId: string): Promise<LayerFilters | null>;
650
- /**
651
- * Sets the **ephemeral** filters for a layer.
652
- *
653
- * @example
654
- * ```typescript
655
- * await felt.setLayerFilters({
656
- * layerId: "layer-1",
657
- * filters: ["AREA", "gt", 30_000],
658
- * });
659
- * ```
660
- */
661
- setLayerFilters(params: {
662
- /**
663
- * The layer that you want to set the filters for.
664
- */
665
- layerId: string;
666
- /**
667
- * The filters to set for the layer. This will replace any ephemeral filters
668
- * that are currently set for the layer.
669
- */
670
- filters: Filters;
671
- /**
672
- * A note to display on the layer legend when this filter is applied. When the
673
- * note is shown, a reset button will also be shown, allowing the user to clear
674
- * the filter.
675
- */
676
- note?: string;
677
- }): Promise<void>;
678
- /**
679
- * Adds a listener for when a layer's filters change.
680
- *
681
- * @returns A function to unsubscribe from the listener
682
- *
683
- * @remarks
684
- * This event fires whenever any type of filter changes on the layer, including
685
- * ephemeral filters set via the SDK, style-based filters, or filters set through
686
- * the Felt UI via Components.
687
- *
688
- * @event
689
- * @example
690
- * ```typescript
691
- * const unsubscribe = felt.onLayerFiltersChange({
692
- * options: { layerId: "layer-1" },
693
- * handler: ({combined, ephemeral, style, components}) => {
694
- * console.log("Layer filters updated:", {
695
- * combined, // All filters combined
696
- * ephemeral, // Filters set via SDK
697
- * style, // Filters from layer style
698
- * components // Filters from UI components
699
- * });
700
- * },
701
- * });
702
- *
703
- * // later on...
704
- * unsubscribe();
705
- * ```
706
- */
707
- onLayerFiltersChange(params: {
708
- options: {
709
- layerId: string;
710
- };
711
- handler: (change: LayerFilters) => void;
712
- }): VoidFunction;
713
- /**
714
- * Get the features that are currently **rendered** on the map in the viewport.
715
- *
716
- * Note that this is explicitly about the features that are rendered, which isn't
717
- * necessarily a complete list of all the features in the viewport. This is because
718
- * of the way features are tiled: at low zoom levels or high feature densities, many
719
- * features are omitted from what is rendered on the screen.
720
- *
721
- * @example
722
- * ```typescript
723
- * const features = await felt.getRenderedFeatures();
724
- * ```
725
- */
726
- getRenderedFeatures(
727
- /**
728
- * The constraints to apply to the features returned from the map.
729
- */
730
- params?: GetRenderedFeaturesConstraint): Promise<Array<LayerFeature>>;
731
- /**
732
- * Get a feature from the map by its ID and layer ID.
733
- *
734
- * The response is a {@link LayerFeature} object, which does not include the
735
- * geometry of the feature.
736
- *
737
- * You may want to use this when you don't need the geometry of a feature,
738
- * but you know the ID of the feature you need.
739
- *
740
- * @example
741
- * ```typescript
742
- * const feature = await felt.getFeature({ layerId: "layer-1", id: 123 });
743
- * ```
744
- */
745
- getFeature(params: {
746
- id: string | number;
747
- layerId: string;
748
- }): Promise<LayerFeature | null>;
749
- /**
750
- * Get a feature in GeoJSON format from the map by its ID and layer ID.
751
- *
752
- * The response is a GeoJSON Feature object with the complete geometry of the
753
- * feature. Note that for some _very_ large geometries, the response may take a
754
- * long time to return, and may return a very large object.
755
- *
756
- * @example
757
- * ```typescript
758
- * const feature = await felt.getGeoJsonFeature({ layerId: "layer-1", id: 123 });
759
- * ```
760
- */
761
- getGeoJsonFeature(params: {
762
- id: string | number;
763
- layerId: string;
764
- }): Promise<GeoJsonFeature | null>;
765
- /**
766
- * Gets values from a layer grouped by a given attribute.
767
- *
768
- * @remarks
769
- * Groups features in your layer by unique values in the specified attribute and calculates
770
- * a value for each group. By default, this value is the count of features in each group.
771
- *
772
- * You can apply filters in two ways:
773
- * 1. At the top level (using `boundary` and `filters`), which affects both what categories
774
- * are included and how values are calculated
775
- * 2. In the `values` configuration, which only affects the values but keeps all categories
776
- *
777
- * This two-level filtering is particularly useful when you want to compare subsets of data
778
- * while maintaining consistent categories. For example, you might want to show the distribution
779
- * of all building types in a city, but only count buildings built after 2000 in each category.
780
- *
781
- * @example
782
- * ```typescript
783
- * // Basic grouping: Count of buildings by type
784
- * const buildingsByType = await felt.getCategoryData({
785
- * layerId: "buildings",
786
- * attribute: "type"
787
- * });
788
- *
789
- * // Filtered grouping: Only count buildings in downtown
790
- * const downtownBuildingsByType = await felt.getCategoryData({
791
- * layerId: "buildings",
792
- * attribute: "type",
793
- * boundary: [-122.43, 47.60, -122.33, 47.62] // downtown boundary
794
- * });
795
- *
796
- * // Advanced: Show all building types, but only sum floor area of recent buildings
797
- * const recentBuildingAreaByType = await felt.getCategoryData({
798
- * layerId: "buildings",
799
- * attribute: "type",
800
- * values: {
801
- * filters: ["year_built", "gte", 2000],
802
- * aggregation: {
803
- * method: "sum",
804
- * attribute: "floor_area"
805
- * }
806
- * }
807
- * });
808
- *
809
- * // Compare residential density across neighborhoods while only counting recent buildings
810
- * const newBuildingDensityByNeighborhood = await felt.getCategoryData({
811
- * layerId: "buildings",
812
- * attribute: "neighborhood",
813
- * values: {
814
- * filters: ["year_built", "gte", 2000],
815
- * aggregation: {
816
- * method: "avg",
817
- * attribute: "units_per_acre"
818
- * }
819
- * }
820
- * });
821
- * ```
822
- */
823
- getCategoryData(params: GetLayerCategoriesParams): Promise<Array<GetLayerCategoriesGroup>>;
824
- /**
825
- * Gets a histogram of values from a layer for a given attribute.
826
- *
827
- * @remarks
828
- * Creates bins (ranges) for numeric data and counts how many features fall into each bin,
829
- * or returns aggregated values for each bin.
830
- *
831
- * You can control how the bins are created using the `steps` parameter, choosing from
832
- * several methods like equal intervals, quantiles, or natural breaks (Jenks), or passing
833
- * in the step values directly if you know how you want to bin the data.
834
- *
835
- * Like getCategoryData, you can apply filters in two ways:
836
- * 1. At the top level (using `boundary` and `filters`), which affects both how the bins
837
- * are calculated and what features are counted in each bin
838
- * 2. In the `values` configuration, which only affects what gets counted but keeps the
839
- * bin ranges the same
840
- *
841
- * This is particularly useful when you want to compare distributions while keeping
842
- * consistent bin ranges. For example, you might want to compare the distribution of
843
- * building heights in different years while using the same height ranges.
844
- *
845
- * @example
846
- * ```typescript
847
- * // Basic histogram: Building heights in 5 natural break bins
848
- * const buildingHeights = await felt.getHistogramData({
849
- * layerId: "buildings",
850
- * attribute: "height",
851
- * steps: { type: "jenks", count: 5 }
852
- * });
853
- *
854
- * // Compare old vs new buildings using the same height ranges
855
- * const oldBuildingHeights = await felt.getHistogramData({
856
- * layerId: "buildings",
857
- * attribute: "height",
858
- * steps: [0, 20, 50, 100, 200, 500],
859
- * values: {
860
- * filters: ["year_built", "lt", 1950]
861
- * }
862
- * });
863
- *
864
- * const newBuildingHeights = await felt.getHistogramData({
865
- * layerId: "buildings",
866
- * attribute: "height",
867
- * steps: [0, 20, 50, 100, 200, 500], // Same ranges as above
868
- * values: {
869
- * filters: ["year_built", "gte", 1950]
870
- * }
871
- * });
872
- * ```
873
- */
874
- getHistogramData(params: GetLayerHistogramParams): Promise<Array<GetLayerHistogramBin>>;
875
- /**
876
- * Calculates a single aggregate value for a layer based on the provided configuration.
877
- *
878
- * @remarks
879
- * Performs statistical calculations on your data, like counting features or computing
880
- * averages, sums, etc. You can focus your calculation on specific areas or subsets
881
- * of your data using boundaries and filters.
882
- *
883
- * When no aggregation is specified, it counts features. When an aggregation is provided,
884
- * it performs that calculation (average, sum, etc.) on the specified attribute.
885
- *
886
- * @example
887
- * ```typescript
888
- * // Count all residential buildings
889
- * const residentialCount = await felt.getAggregates({
890
- * layerId: "buildings",
891
- * filters: ["type", "eq", "residential"]
892
- * });
893
- *
894
- * // Calculate average home value in a specific neighborhood
895
- * const avgHomeValue = await felt.getAggregates({
896
- * layerId: "buildings",
897
- * boundary: [-122.43, 47.60, -122.33, 47.62], // neighborhood boundary
898
- * aggregation: {
899
- * method: "avg",
900
- * attribute: "assessed_value"
901
- * }
902
- * });
903
- *
904
- * // Find the maximum building height for buildings built after 2000
905
- * const maxNewBuildingHeight = await felt.getAggregates({
906
- * layerId: "buildings",
907
- * filters: ["year_built", "gte", 2000],
908
- * aggregation: {
909
- * method: "max",
910
- * attribute: "height"
911
- * }
912
- * });
913
- * ```
914
- */
915
- getAggregates<T extends AggregationMethod | "count">(params: GetLayerCalculationParams<T>): Promise<Record<T, number | null>>;
916
- /**
917
- * Get the schema for a layer.
918
- *
919
- * @remarks
920
- * The schema describes the structure of the data in a layer, including the attributes
921
- * that are available on the features in the layer.
922
- *
923
- * This can be useful to build generic UIs that need to know the structure of the data in
924
- * a layer, such as a dropdown to choose an attribute.
925
- *
926
- * @example
927
- * ```typescript
928
- * const schema = await felt.getLayerSchema("layer-1");
929
- * const attributeIds = schema.attributes.map((attr) => attr.id);
930
- * ```
931
- */
932
- getLayerSchema(layerId: string): Promise<LayerSchema>;
933
- }
934
-
935
314
  /**
936
315
  * The Interactions controller allows you to observe interactions with the map
937
316
  *
@@ -1795,4 +1174,4 @@ declare const Felt: {
1795
1174
  connect(feltWindow: Pick<Window, "postMessage">): Promise<FeltController>;
1796
1175
  };
1797
1176
 
1798
- 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, UpdateLayerParams, 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 };