Skip to content

Add preloaded bookmarks support#76

Merged
giswqs merged 1 commit intomainfrom
add-preloaded-bookmarks
Mar 8, 2026
Merged

Add preloaded bookmarks support#76
giswqs merged 1 commit intomainfrom
add-preloaded-bookmarks

Conversation

@giswqs
Copy link
Copy Markdown
Member

@giswqs giswqs commented Mar 8, 2026

Summary

  • Add bookmarkOptions to ControlGridOptions so bookmark settings (including preloaded bookmarks) can be passed through addControlGrid()
  • Add preloaded bookmarks (San Francisco, New York City, London, Tokyo, Paris) to both the bookmark-control and add-control-grid examples

Test plan

  • Verify bookmark-control example shows 5 preloaded bookmarks on first load
  • Verify add-control-grid example passes bookmarkOptions through to the BookmarkControl
  • Verify clicking a preloaded bookmark flies to the correct location

- 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
Copilot AI review requested due to automatic review settings March 8, 2026 00:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ControlGridOptions with bookmarkOptions?: Partial<BookmarkControlOptions>.
  • Pass bookmarkOptions through 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.

Comment on lines +12 to +20
// 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: [
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +63
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,
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@giswqs giswqs merged commit 33f8f6c into main Mar 8, 2026
6 checks passed
@giswqs giswqs deleted the add-preloaded-bookmarks branch March 8, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants