@feltmaps/js-sdk 1.5.0-next.8 → 1.5.1

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 g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var G=(e,n)=>{for(var r in n)g(e,r,{get:n[r],enumerable:!0})},I=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of b(n))!S.call(e,l)&&l!==r&&g(e,l,{get:()=>n[l],enumerable:!(s=F(n,l))||s.enumerable});return e};var x=e=>I(g({},"__esModule",{value:!0}),e);var K={};G(K,{Felt:()=>M});module.exports=x(K);function o(e,n){return r=>{let s=new MessageChannel,l=r.handler,a="options"in r?r.options:void 0,i=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:a?{eventName:n,id:i,options:a}:{eventName:n,id:i}},"*",[s.port2]),s.port1.onmessage=d=>{l(d.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:i},"*")}}}function t(e,n){return r=>{let s=new MessageChannel;return e.postMessage({type:n,params:r},"*",[s.port2]),new Promise((l,a)=>{s.port1.onmessage=i=>{i.data&&typeof i.data=="object"&&"__error__"in i.data?a(new Error(i.data.__error__)):l(i.data),s.port1.close(),s.port2.close()}})}}var u=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:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementCreateEnd:o(e,"onElementCreateEnd"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var C=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var h=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),onLayerFiltersChange:o(e,"onLayerFiltersChange"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var L=e=>({getMapDetails:t(e,"getMapDetails")});var T=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var E=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var v=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi"),showLayerDataTable:t(e,"showLayerDataTable"),hideLayerDataTable:t(e,"hideLayerDataTable")});var P=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function V(e){return{iframe:null,...P(e),...v(e),...h(e),...u(e),...T(e),...C(e),...E(e),...L(e)}}var M={embed(e,n,r){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},l=r?.origin??s.origin,a=new URL(`${l}/embed/map/${n}`),i={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...s.uiControls,...r?.uiControls};for(let[p,y]of f(d))y!=null&&a.searchParams.set(i[p],y?"1":"0");if(r?.token&&a.searchParams.set("token",r.token),r?.initialViewport){let p=r.initialViewport;a.searchParams.set("loc",`${p.center.latitude},${p.center.longitude},${p.zoom}z`)}let c=e.tagName==="IFRAME",m=c?e:e.ownerDocument.createElement("iframe");return m.src=a.toString(),c||(m.style.width="100%",m.style.height="100%",m.style.border="none",m.style.margin="0",e.appendChild(m)),m.referrerPolicy="strict-origin-when-cross-origin",new Promise((p,y)=>{m.addEventListener("load",()=>{m.contentWindow==null?y(new Error("Failed to load Felt map")):p(m.contentWindow)},{once:!0})}).then(M.connect).then(p=>(Object.defineProperties(p,{iframe:{value:m,writable:!1,configurable:!1}}),p))},connect(e){let n=V(e);return new Promise((r,s)=>{let l=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(i)},5e3),a=new MessageChannel,i=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[a.port2])},100);a.port1.onmessage=d=>{d.data===!0&&(clearInterval(i),clearTimeout(l),a.port1.close(),a.port2.close(),r(n))}})}},f=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=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});
package/dist/client.d.cts 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-BXCTpxot.cjs';
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-BXCTpxot.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, 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';
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,10 +282,31 @@ interface ElementsController {
265
282
  createElement(element: ElementCreate): Promise<Element>;
266
283
  /**
267
284
  * Update an element on the map.
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * // Update a place element's coordinates
289
+ * await felt.updateElement({
290
+ * id: "element-1",
291
+ * coordinates: [10, 20]
292
+ * });
293
+ *
294
+ * // Update a polygon's style
295
+ * await felt.updateElement({
296
+ * id: "element-2",
297
+ * color: "#ABC123",
298
+ * fillOpacity: 0.5
299
+ * });
300
+ * ```
268
301
  */
269
302
  updateElement(element: ElementUpdate): Promise<Element>;
270
303
  /**
271
304
  * Delete an element from the map.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * await felt.deleteElement("element-1");
309
+ * ```
272
310
  */
273
311
  deleteElement(id: string): Promise<void>;
274
312
  }
@@ -405,6 +443,70 @@ interface LayersController {
405
443
  */
406
444
  change: LayerChangeCallbackParams) => void;
407
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>;
408
510
  /**
409
511
  * Get a layer group from the map by its id.
410
512
  *
@@ -550,7 +652,7 @@ interface LayersController {
550
652
  *
551
653
  * @example
552
654
  * ```typescript
553
- * felt.setLayerFilters({
655
+ * await felt.setLayerFilters({
554
656
  * layerId: "layer-1",
555
657
  * filters: ["AREA", "gt", 30_000],
556
658
  * });
@@ -625,7 +727,41 @@ interface LayersController {
625
727
  /**
626
728
  * The constraints to apply to the features returned from the map.
627
729
  */
628
- params?: GetRenderedFeaturesConstraint): Promise<Array<Feature>>;
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>;
629
765
  /**
630
766
  * Gets values from a layer grouped by a given attribute.
631
767
  *
@@ -777,6 +913,23 @@ interface LayersController {
777
913
  * ```
778
914
  */
779
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>;
780
933
  }
781
934
 
782
935
  /**
@@ -813,8 +966,12 @@ interface InteractionsController {
813
966
  * @event
814
967
  * @example
815
968
  * ```typescript
969
+ * // Track mouse movement and features under cursor
816
970
  * const unsubscribe = felt.onPointerMove({
817
- * handler: (event) => console.log(event.center, event.features),
971
+ * handler: (event) => {
972
+ * console.log("Mouse position:", event.center);
973
+ * console.log("Features under cursor:", event.features);
974
+ * }
818
975
  * });
819
976
  *
820
977
  * // later on...
@@ -840,6 +997,16 @@ interface InteractionsController {
840
997
  interface MiscController {
841
998
  /**
842
999
  * Gets the details of the map.
1000
+ *
1001
+ * @example
1002
+ * ```typescript
1003
+ * const details = await felt.getMapDetails();
1004
+ * console.log({
1005
+ * id: details.id,
1006
+ * title: details.title,
1007
+ * description: details.description,
1008
+ * });
1009
+ * ```
843
1010
  */
844
1011
  getMapDetails(): Promise<MapDetails>;
845
1012
  }
@@ -960,10 +1127,10 @@ interface ToolsController {
960
1127
  * @example
961
1128
  * ```typescript
962
1129
  * // Set the tool to "marker"
963
- * felt.setTool("marker");
1130
+ * await felt.setTool("marker");
964
1131
  *
965
1132
  * // put down the tool
966
- * felt.setTool(null);
1133
+ * await felt.setTool(null);
967
1134
  * ```
968
1135
  */
969
1136
  setTool(tool: ToolType | null): void;
@@ -1004,18 +1171,41 @@ interface ToolsController {
1004
1171
  /**
1005
1172
  * Sets the settings for the current tool.
1006
1173
  *
1174
+ * @example
1175
+ * ```typescript
1176
+ * // Set the settings for the marker tool
1177
+ * await felt.setToolSettings({
1178
+ * tool: "marker",
1179
+ * color: "#FE17",
1180
+ * });
1181
+ * ```
1182
+ *
1007
1183
  * @param settings - The settings to set.
1008
1184
  */
1009
1185
  setToolSettings(settings: InputToolSettings): void;
1010
1186
  /**
1011
- * Gets the settings for the current tool.
1187
+ * Gets the settings for the chosen tool
1188
+ *
1189
+ * @example
1190
+ * ```typescript
1191
+ * const settings = await felt.getToolSettings("marker");
1192
+ * ```
1012
1193
  *
1013
- * @returns The settings for the current tool.
1194
+ * @returns The settings for the chosen tool.
1014
1195
  */
1015
1196
  getToolSettings<T extends ConfigurableToolType>(tool: T): Promise<ToolSettingsMap[T]>;
1016
1197
  /**
1017
1198
  * Listens for changes to the settings on all tools.
1018
1199
  *
1200
+ * @example
1201
+ * ```typescript
1202
+ * const unsubscribe = felt.onToolSettingsChange({
1203
+ * handler: settings => console.log(settings),
1204
+ * });
1205
+ *
1206
+ * // later on...
1207
+ * unsubscribe();
1208
+ * ```
1019
1209
  * @returns A function to unsubscribe from the listener
1020
1210
  */
1021
1211
  onToolSettingsChange(args: {
@@ -1174,6 +1364,21 @@ interface UiController {
1174
1364
  /**
1175
1365
  * Updates the UI controls on the embedded map.
1176
1366
  *
1367
+ * @example
1368
+ * ```typescript
1369
+ * // Show some UI controls
1370
+ * await felt.updateUiControls({
1371
+ * showLegend: true,
1372
+ * fullScreenButton: true,
1373
+ * });
1374
+ *
1375
+ * // Disable some UI options
1376
+ * await felt.updateUiControls({
1377
+ * cooperativeGestures: false,
1378
+ * geolocation: false,
1379
+ * });
1380
+ * ```
1381
+ *
1177
1382
  * @param controls - The controls to update.
1178
1383
  */
1179
1384
  updateUiControls(controls: UiControlsOptions): void;
@@ -1187,6 +1392,15 @@ interface UiController {
1187
1392
  *
1188
1393
  * This does not affect selection. That means that selectable features and elements
1189
1394
  * will still be selected when clicked.
1395
+ *
1396
+ * @example
1397
+ * ```typescript
1398
+ * // Disable UI when hovering or selecting features
1399
+ * await felt.setOnMapInteractionsUi({
1400
+ * featureSelectPanel: false,
1401
+ * featureHoverPanel: false,
1402
+ * });
1403
+ * ```
1190
1404
  */
1191
1405
  setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void;
1192
1406
  /**
@@ -1239,6 +1453,16 @@ interface UiController {
1239
1453
  interface ViewportController {
1240
1454
  /**
1241
1455
  * Gets the current state of the viewport.
1456
+ *
1457
+ * @example
1458
+ * ```typescript
1459
+ * // Get current viewport state
1460
+ * const viewport = await felt.getViewport();
1461
+ * console.log({
1462
+ * center: viewport.center,
1463
+ * zoom: viewport.zoom,
1464
+ * });
1465
+ * ```
1242
1466
  */
1243
1467
  getViewport(): Promise<ViewportState>;
1244
1468
  /**
@@ -1255,6 +1479,21 @@ interface ViewportController {
1255
1479
  setViewport(viewport: SetViewportCenterZoomParams): void;
1256
1480
  /**
1257
1481
  * Gets the current state of the viewport constraints.
1482
+ *
1483
+ * @example
1484
+ * ```typescript
1485
+ * // Get current viewport constraints
1486
+ * const constraints = await felt.getViewportConstraints();
1487
+ * if (constraints) {
1488
+ * console.log({
1489
+ * bounds: constraints.bounds,
1490
+ * minZoom: constraints.minZoom,
1491
+ * maxZoom: constraints.maxZoom
1492
+ * });
1493
+ * } else {
1494
+ * console.log("No viewport constraints set");
1495
+ * }
1496
+ * ```
1258
1497
  */
1259
1498
  getViewportConstraints(): Promise<ViewportConstraints | null>;
1260
1499
  /**
@@ -1449,17 +1688,17 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1449
1688
  }>;
1450
1689
  zoom: z.ZodNumber;
1451
1690
  }, "strip", z.ZodTypeAny, {
1452
- zoom: number;
1453
1691
  center: {
1454
1692
  latitude: number;
1455
1693
  longitude: number;
1456
1694
  };
1457
- }, {
1458
1695
  zoom: number;
1696
+ }, {
1459
1697
  center: {
1460
1698
  latitude: number;
1461
1699
  longitude: number;
1462
1700
  };
1701
+ zoom: number;
1463
1702
  }>>;
1464
1703
  }, "strip", z.ZodTypeAny, {
1465
1704
  origin?: string | undefined;
@@ -1473,11 +1712,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1473
1712
  scaleBar?: boolean | undefined;
1474
1713
  } | undefined;
1475
1714
  initialViewport?: {
1476
- zoom: number;
1477
1715
  center: {
1478
1716
  latitude: number;
1479
1717
  longitude: number;
1480
1718
  };
1719
+ zoom: number;
1481
1720
  } | undefined;
1482
1721
  }, {
1483
1722
  origin?: string | undefined;
@@ -1491,11 +1730,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1491
1730
  scaleBar?: boolean | undefined;
1492
1731
  } | undefined;
1493
1732
  initialViewport?: {
1494
- zoom: number;
1495
1733
  center: {
1496
1734
  latitude: number;
1497
1735
  longitude: number;
1498
1736
  };
1737
+ zoom: number;
1499
1738
  } | undefined;
1500
1739
  }>;
1501
1740
 
@@ -1538,12 +1777,13 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
1538
1777
  */
1539
1778
  declare const Felt: {
1540
1779
  /**
1541
- * Embeds a Felt map into the provided container.
1780
+ * Embeds a Felt map into the provided container, returning a promise that resolves
1781
+ * to a {@link FeltController} object that you can use to control the map.
1542
1782
  *
1543
1783
  * @param container - The container element to embed the map into.
1544
1784
  * @param mapId - The ID of the map to embed.
1545
1785
  * @param options - The options to configure the map.
1546
- * @returns
1786
+ * @returns A promise for a {@link FeltController}.
1547
1787
  */
1548
1788
  embed(container: HTMLElement, mapId: string, options?: FeltEmbedOptions): Promise<FeltController>;
1549
1789
  /**
@@ -1552,7 +1792,7 @@ declare const Felt: {
1552
1792
  * @param feltWindow - The iframe element containing the Felt map.
1553
1793
  * @returns
1554
1794
  */
1555
- connect(feltWindow: Window): Promise<FeltController>;
1795
+ connect(feltWindow: Pick<Window, "postMessage">): Promise<FeltController>;
1556
1796
  };
1557
1797
 
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 };
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 };