Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/empty-camels-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@feltmaps/js-sdk": minor
---

Add feature actions
90 changes: 90 additions & 0 deletions docs/Main/FeltController.md
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,96 @@ await felt.deleteActionTrigger("enablePolygonTool");

***

## createFeatureAction()

> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](../UI/CreateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>

Creates a feature contextual action.

### Parameters

| Parameter | Type | Description |
| --------- | ----------------------------------------------------------------- | ----------------------------- |
| `args` | [`CreateFeatureActionParams`](../UI/CreateFeatureActionParams.md) | The arguments for the method. |

### Returns

`Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>

### Example

```typescript
const myAction = await felt.createFeatureAction({
action: {
label: "Edit feature",
onTrigger: async ({ featureId, layerId }) => {
console.log(`Editing feature ${featureId} in layer ${layerId}`);
},
layerIds: ["layer-1", "layer-2"],
},
placement: { at: "start" }, // optional, defaults to { at: "end" }
});
```

***

## updateFeatureAction()

> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](../UI/UpdateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>

Updates a feature contextual action.

Feature contextual action to update is identified by the `id` property.

### Parameters

| Parameter | Type | Description |
| --------- | ----------------------------------------------------------------- | ---------------------------------------- |
| `args` | [`UpdateFeatureActionParams`](../UI/UpdateFeatureActionParams.md) | The feature contextual action to update. |

### Returns

`Promise`\<[`uiFeatureAction`](../UI/uiFeatureAction.md)>

### Remarks

Properties provided will override the existing properties.

### Example

```typescript
await felt.updateFeatureAction({
id: "my-action",
label: "Updated action label", // only label changes
});
```

***

## deleteFeatureAction()

> **deleteFeatureAction**(`id`: `string`): `void`

Deletes a feature contextual action.

### Parameters

| Parameter | Type | Description |
| --------- | -------- | -------------------------------------------------- |
| `id` | `string` | The id of the feature contextual action to delete. |

### Returns

`void`

### Example

```typescript
await felt.deleteFeatureAction("my-action");
```

***

## createPanelId()

> **createPanelId**(): `Promise`\<`string`>
Expand Down
13 changes: 13 additions & 0 deletions docs/UI/CreateFeatureActionParams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
***

# Properties

## action

> **action**: [`uiFeatureActionCreate`](uiFeatureActionCreate.md)

***

## placement?

> `optional` **placement**: \{ `after`: `string`; } | \{ `before`: `string`; } | \{ `at`: `"start"` | `"end"`; }
4 changes: 4 additions & 0 deletions docs/UI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ UI features such as the legend and the full screen button.

* [CreateActionTriggerParams](CreateActionTriggerParams.md)
* [UpdateActionTriggerParams](UpdateActionTriggerParams.md)
* [CreateFeatureActionParams](CreateFeatureActionParams.md)
* [UpdateFeatureActionParams](UpdateFeatureActionParams.md)
* [CreateOrUpdatePanelParams](CreateOrUpdatePanelParams.md)
* [CreatePanelElementsParams](CreatePanelElementsParams.md)
* [UpdatePanelElementsParams](UpdatePanelElementsParams.md)
Expand All @@ -30,6 +32,7 @@ UI features such as the legend and the full screen button.
* [UIDividerElement](UIDividerElement.md)
* [UIDividerElementCreate](UIDividerElementCreate.md)
* [UIDividerElementUpdate](UIDividerElementUpdate.md)
* [uiFeatureActionCreate](uiFeatureActionCreate.md)
* [UIFlexibleSpaceElement](UIFlexibleSpaceElement.md)
* [UIFlexibleSpaceElementCreate](UIFlexibleSpaceElementCreate.md)
* [UIFlexibleSpaceElementUpdate](UIFlexibleSpaceElementUpdate.md)
Expand Down Expand Up @@ -60,6 +63,7 @@ UI features such as the legend and the full screen button.

# Type Aliases

* [uiFeatureAction](uiFeatureAction.md)
* [PlacementForUIElement](PlacementForUIElement.md)
* [UIPanelElement](UIPanelElement.md)
* [UIPanelElementCreate](UIPanelElementCreate.md)
Expand Down
90 changes: 90 additions & 0 deletions docs/UI/UiController.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,96 @@ await felt.deleteActionTrigger("enablePolygonTool");

***

## createFeatureAction()

> **createFeatureAction**(`args`: [`CreateFeatureActionParams`](CreateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>

Creates a feature contextual action.

### Parameters

| Parameter | Type | Description |
| --------- | ----------------------------------------------------------- | ----------------------------- |
| `args` | [`CreateFeatureActionParams`](CreateFeatureActionParams.md) | The arguments for the method. |

### Returns

`Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>

### Example

```typescript
const myAction = await felt.createFeatureAction({
action: {
label: "Edit feature",
onTrigger: async ({ featureId, layerId }) => {
console.log(`Editing feature ${featureId} in layer ${layerId}`);
},
layerIds: ["layer-1", "layer-2"],
},
placement: { at: "start" }, // optional, defaults to { at: "end" }
});
```

***

## updateFeatureAction()

> **updateFeatureAction**(`args`: [`UpdateFeatureActionParams`](UpdateFeatureActionParams.md)): `Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>

Updates a feature contextual action.

Feature contextual action to update is identified by the `id` property.

### Parameters

| Parameter | Type | Description |
| --------- | ----------------------------------------------------------- | ---------------------------------------- |
| `args` | [`UpdateFeatureActionParams`](UpdateFeatureActionParams.md) | The feature contextual action to update. |

### Returns

`Promise`\<[`uiFeatureAction`](uiFeatureAction.md)>

### Remarks

Properties provided will override the existing properties.

### Example

```typescript
await felt.updateFeatureAction({
id: "my-action",
label: "Updated action label", // only label changes
});
```

***

## deleteFeatureAction()

> **deleteFeatureAction**(`id`: `string`): `void`

Deletes a feature contextual action.

### Parameters

| Parameter | Type | Description |
| --------- | -------- | -------------------------------------------------- |
| `id` | `string` | The id of the feature contextual action to delete. |

### Returns

`void`

### Example

```typescript
await felt.deleteFeatureAction("my-action");
```

***

## createPanelId()

> **createPanelId**(): `Promise`\<`string`>
Expand Down
42 changes: 42 additions & 0 deletions docs/UI/UpdateFeatureActionParams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
***

# Properties

## id

> **id**: `string`

***

## label?

> `optional` **label**: `string`

***

## layerIds?

> `optional` **layerIds**: `string`\[]

***

## geometryTypes?

> `optional` **geometryTypes**: (`"Polygon"` | `"Point"` | `"Line"` | `"Raster"`)\[]

***

## onTrigger()?

> `optional` **onTrigger**: (`args`: \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); }) => `void`

### Parameters

| Parameter | Type |
| -------------- | ------------------------------------------------------------ |
| `args` | \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); } |
| `args.feature` | [`LayerFeature`](../Layers/LayerFeature.md) |

### Returns

`void`
38 changes: 38 additions & 0 deletions docs/UI/uiFeatureAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
***

> **uiFeatureAction**: \{ `id`: `string`; `label`: `string`; `onTrigger`: (`args`: \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); }) => `void`; `layerIds`: `string`\[]; `geometryTypes`: (`"Polygon"` | `"Point"` | `"Line"` | `"Raster"`)\[]; }

Represents a feature action after creation (with generated id).

# Type declaration

## id

> **id**: `string`

## label

> **label**: `string`

## onTrigger()

> **onTrigger**: (`args`: \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); }) => `void`

### Parameters

| Parameter | Type |
| -------------- | ------------------------------------------------------------ |
| `args` | \{ `feature`: [`LayerFeature`](../Layers/LayerFeature.md); } |
| `args.feature` | [`LayerFeature`](../Layers/LayerFeature.md) |

### Returns

`void`

## layerIds?

> `optional` **layerIds**: `string`\[]

## geometryTypes?

> `optional` **geometryTypes**: (`"Polygon"` | `"Point"` | `"Line"` | `"Raster"`)\[]
Loading