-
Notifications
You must be signed in to change notification settings - Fork 5
Add preloaded bookmarks support #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,14 +9,66 @@ const map = new maplibregl.Map({ | |
| }); | ||
|
|
||
| map.on("load", () => { | ||
| // Add the BookmarkControl with localStorage persistence | ||
| // 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: [ | ||
|
Comment on lines
+12
to
+20
|
||
| { | ||
| 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, | ||
| zoom: 12, | ||
| pitch: 0, | ||
| bearing: 0, | ||
| createdAt: Date.now(), | ||
| }, | ||
| { | ||
| id: "london", | ||
| name: "London", | ||
| lng: -0.1276, | ||
| lat: 51.5074, | ||
| zoom: 11, | ||
| pitch: 0, | ||
| bearing: 0, | ||
| createdAt: Date.now(), | ||
| }, | ||
| { | ||
| id: "tokyo", | ||
| name: "Tokyo", | ||
| lng: 139.6917, | ||
| lat: 35.6895, | ||
| zoom: 11, | ||
| pitch: 0, | ||
| bearing: 0, | ||
| createdAt: Date.now(), | ||
| }, | ||
| { | ||
| id: "paris", | ||
| name: "Paris", | ||
| lng: 2.3522, | ||
| lat: 48.8566, | ||
| zoom: 12, | ||
| pitch: 0, | ||
| bearing: 0, | ||
| createdAt: Date.now(), | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| map.addControl(bookmarkControl, "top-right"); | ||
|
|
@@ -38,11 +90,4 @@ map.on("load", () => { | |
| console.log("Bookmarks imported:", event.state.bookmarks.length, "total"); | ||
| }); | ||
|
|
||
| // Add some sample bookmarks if none exist | ||
| if (bookmarkControl.getBookmarks().length === 0) { | ||
| // Navigate to SF and add bookmark | ||
| map.once("moveend", () => { | ||
| bookmarkControl.addBookmark("San Francisco"); | ||
| }); | ||
| } | ||
| }); | ||
There was a problem hiding this comment.
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.