Conversation
- Add bookmarkOptions to ControlGridOptions so bookmark settings (including preloaded bookmarks) can be passed through addControlGrid() - Add preloaded bookmarks (SF, NYC, London, Tokyo, Paris) to both the bookmark-control and add-control-grid examples
There was a problem hiding this comment.
Pull request overview
This PR adds support for passing BookmarkControl configuration (including preloaded bookmarks) through addControlGrid() / ControlGrid, and updates examples to demonstrate preloaded bookmarks.
Changes:
- Extend
ControlGridOptionswithbookmarkOptions?: Partial<BookmarkControlOptions>. - Pass
bookmarkOptionsthrough when ControlGrid instantiates the default"bookmark"control. - Add 5 preloaded city bookmarks to the bookmark-control and add-control-grid examples.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib/core/types.ts | Adds bookmarkOptions to ControlGridOptions with inline JSDoc example. |
| src/lib/core/ControlGrid.ts | Adds bookmarkOptions to resolved defaults and forwards it into new BookmarkControl(...). |
| examples/bookmark-control/main.ts | Demonstrates BookmarkControl with localStorage persistence plus 5 preloaded bookmarks. |
| examples/add-control-grid/main.ts | Demonstrates passing bookmarkOptions through addControlGrid() to the default BookmarkControl. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Add the BookmarkControl with localStorage persistence and preloaded bookmarks | ||
| const bookmarkControl = new BookmarkControl({ | ||
| position: "top-right", | ||
| collapsed: true, | ||
| storageKey: "maplibre-bookmarks-demo", | ||
| maxBookmarks: 20, | ||
| flyToDuration: 2000, | ||
| generateThumbnails: false, | ||
| bookmarks: [ |
There was a problem hiding this comment.
Because storageKey is set, any existing localStorage value for this key (including a previously-saved empty array) will override the bookmarks you pass in, so the “preloaded bookmarks” may not appear for developers who have run this example before. Consider using a versioned/unique storageKey for the example, clearing the key on startup, or noting that localStorage must be cleared to see the preloaded set.
| bookmarks: [ | ||
| { | ||
| id: "san-francisco", | ||
| name: "San Francisco", | ||
| lng: -122.4194, | ||
| lat: 37.7749, | ||
| zoom: 12, | ||
| pitch: 0, | ||
| bearing: 0, | ||
| createdAt: Date.now(), | ||
| }, | ||
| { | ||
| id: "new-york", | ||
| name: "New York City", | ||
| lng: -74.006, | ||
| lat: 40.7128, |
There was a problem hiding this comment.
The file mostly uses single quotes, but the newly added bookmark IDs/names use double quotes. If this repo enforces quote style via linting/formatting, this will fail CI or cause noisy diffs later—please make the new strings consistent with the rest of this file’s quote style.
Summary
bookmarkOptionstoControlGridOptionsso bookmark settings (including preloaded bookmarks) can be passed throughaddControlGrid()Test plan