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

Add `rotation` and `contextMenu` UI control options, for disabling map rotation and the right-click menu via `Felt.embed` and `updateUiControls`
40 changes: 40 additions & 0 deletions docs/UI/UiControlsOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,43 @@ Whether or not the scale bar is shown in an embedded map.
```ts
true
```

***

## rotation?

> `optional` **rotation**: `boolean`

Whether or not the map can be rotated.

### Remarks

This affects all rotation interactions — dragging with the right mouse
button or Ctrl held, two-finger touch rotation, and keyboard shortcuts —
as well as the compass control, which is hidden when rotation is
disabled.

### Default Value

```ts
true
```

***

## contextMenu?

> `optional` **contextMenu**: `boolean`

Whether or not the right-click context menu is available on the map.

### Remarks

When disabled, right-clicking the map opens neither Felt's context menu
nor the browser's own.

### Default Value

```ts
true
```
434 changes: 222 additions & 212 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.

4 changes: 4 additions & 0 deletions src/modules/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export const Felt = {
geolocation: false,
zoomControls: true,
scaleBar: true,
rotation: true,
contextMenu: true,
},
initialViewport: undefined,
origin: "https://felt.com",
Expand All @@ -76,6 +78,8 @@ export const Felt = {
geolocation: "geolocation",
zoomControls: "zoomControls",
scaleBar: "scaleBar",
rotation: "rotation",
contextMenu: "contextMenu",
};

const uiControlsOptions = {
Expand Down
24 changes: 24 additions & 0 deletions src/modules/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,30 @@ export const UiControlsOptionsSchema = z.object({
* @defaultValue true
*/
scaleBar: z.boolean().optional(),

/**
* Whether or not the map can be rotated.
*
* @remarks
* This affects all rotation interactions — dragging with the right mouse
* button or Ctrl held, two-finger touch rotation, and keyboard shortcuts —
* as well as the compass control, which is hidden when rotation is
* disabled.
*
* @defaultValue true
*/
rotation: z.boolean().optional(),

/**
* Whether or not the right-click context menu is available on the map.
*
* @remarks
* When disabled, right-clicking the map opens neither Felt's context menu
* nor the browser's own.
*
* @defaultValue true
*/
contextMenu: z.boolean().optional(),
});

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ describe("Embedding an iframe with theFelt SDK", () => {
uiControls: {
showLegend: false,
zoomControls: false,
rotation: false,
contextMenu: false,
},
initialViewport: {
center: { latitude: 40, longitude: -74 },
Expand All @@ -103,6 +105,8 @@ describe("Embedding an iframe with theFelt SDK", () => {
expect(url.origin).toBe("https://example.com");
expect(url.searchParams.get("legend")).toBe("0");
expect(url.searchParams.get("zoomControls")).toBe("0");
expect(url.searchParams.get("rotation")).toBe("0");
expect(url.searchParams.get("contextMenu")).toBe("0");
expect(url.searchParams.get("loc")).toBe("40,-74,10z");
expect(url.searchParams.get("token")).toBe("test-token");
});
Expand Down
Loading