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/sharp-files-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@feltmaps/js-sdk": minor
---

Add duplicateLayer method
7 changes: 4 additions & 3 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ Once you have added your module:

1. Run `npm run build` to ensure everything compiles and the docs are generated. It's possible for the docs to
fail to build if some types are not exported, but you will be warned in the console about this.
1. Run `npm run update-api` to run api-extractor which updates the "api spec" file, which allows
2. Run `npm run update-api` to run api-extractor which updates the "api spec" file, which allows
reviewers to understand the changes made to the API.
1. Stage or commit your changes. This is important, because the next step will fail if you have
3. Stage or commit your changes. This is important, because the next step will fail if you have
docs changes that are unstaged as it is used to check that the docs are up to date.
1. Run `npm run check` which will check that the package is correctly built, the docs have been
4. Run `npm run check` which will check that the package is correctly built, the docs have been
updated, the API spec has been updated and the tests are passing.
5. If you make any further changes, run steps 1 to 4 again.

If this all works, your module is ready and should be working.

Expand Down
30 changes: 30 additions & 0 deletions docs/Layers/LayersController.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,36 @@ await felt.deleteLayer("layer-1");

***

## duplicateLayer()

> **duplicateLayer**(`id`: `string`): `Promise`\<[`Layer`](Layer.md)>

Duplicate a layer from the map by its id.

### Parameters

| Parameter | Type |
| --------- | -------- |
| `id` | `string` |

### Returns

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

The duplicated layer.

### Remarks

This will create an ephemeral copy of the layer, just for the duration of the session. The duplicated layer will not be persisted to the map.

### Example

```typescript
const duplicatedLayer = await felt.duplicateLayer("layer-1");
```

***

## getLayerGroup()

> **getLayerGroup**(`id`: `string`): `Promise`\<`null` | [`LayerGroup`](LayerGroup.md)>
Expand Down
30 changes: 30 additions & 0 deletions docs/Main/FeltController.md
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,36 @@ await felt.deleteLayer("layer-1");

***

## duplicateLayer()

> **duplicateLayer**(`id`: `string`): `Promise`\<[`Layer`](../Layers/Layer.md)>

Duplicate a layer from the map by its id.

### Parameters

| Parameter | Type |
| --------- | -------- |
| `id` | `string` |

### Returns

`Promise`\<[`Layer`](../Layers/Layer.md)>

The duplicated layer.

### Remarks

This will create an ephemeral copy of the layer, just for the duration of the session. The duplicated layer will not be persisted to the map.

### Example

```typescript
const duplicatedLayer = await felt.duplicateLayer("layer-1");
```

***

## getLayerGroup()

> **getLayerGroup**(`id`: `string`): `Promise`\<`null` | [`LayerGroup`](../Layers/LayerGroup.md)>
Expand Down
402 changes: 201 additions & 201 deletions etc/js-sdk.api.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/modules/layers/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const layersController = (
),
updateLayer: method(feltWindow, "updateLayer", convertFileSourceToDataSource),
deleteLayer: method(feltWindow, "deleteLayer"),
duplicateLayer: method(feltWindow, "duplicateLayer"),

// groups
getLayerGroup: method(feltWindow, "getLayerGroup"),
Expand Down Expand Up @@ -345,6 +346,19 @@ export interface LayersController {
*/
deleteLayer(id: string): Promise<void>;

/**
* Duplicate a layer from the map by its id.
*
* @remarks This will create an ephemeral copy of the layer, just for the duration of the session. The duplicated layer will not be persisted to the map.
*
* @example
* ```typescript
* const duplicatedLayer = await felt.duplicateLayer("layer-1");
* ```
* @returns The duplicated layer.
*/
duplicateLayer(id: string): Promise<Layer>;

// GROUPS

/**
Expand Down
6 changes: 4 additions & 2 deletions src/modules/layers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const UpdateLayerMessage = methodMessage("updateLayer", UpdateLayerSchema);

const DeleteLayerMessage = methodMessage("deleteLayer", z.string());

const DuplicateLayerMessage = methodMessage("duplicateLayer", z.string());

// LAYER GROUPS
const GetGroupMessage = methodMessage("getLayerGroup", z.string());
const GetGroupsMessage = methodMessage(
Expand Down Expand Up @@ -209,7 +211,7 @@ export const layersSchema = {
CreateLayersFromGeoJsonMessage,
DeleteLayerMessage,
UpdateLayerMessage,

DuplicateLayerMessage,
GetGroupMessage,
GetGroupsMessage,
SetLayerGroupVisibilityMessage,
Expand Down Expand Up @@ -261,7 +263,7 @@ export type LayersSchema = {
>;
updateLayer: Method<zInfer<typeof UpdateLayerMessage>>;
deleteLayer: Method<zInfer<typeof DeleteLayerMessage>>;

duplicateLayer: Method<zInfer<typeof DuplicateLayerMessage>>;
getLayerGroup: Method<zInfer<typeof GetGroupMessage>>;
getLayerGroups: Method<zInfer<typeof GetGroupsMessage>>;
setLayerGroupVisibility: Method<
Expand Down