import "@arcgis/map-components/components/arcgis-bookmarks";The Bookmarks component allows end users to quickly navigate to a particular area of interest. It displays a list of bookmarks, which are typically defined inside the WebMap.
Each bookmark may contain the following properties: name, thumbnail, viewpoint (defines rotation, scale, and target geometry), and timeExtent.
When a bookmark with a timeExtent is selected, the arcgis-map.timeExtent of the Map will be set to the timeExtent of the selected bookmark.
To disable time capability in the Bookmarks component, set timeDisabled to true.
The Bookmarks component can be used to create, edit, reorder, and delete bookmarks.
To enable these features, set the following properties to true:
showAddBookmarkButton, showEditBookmarkButton, and dragEnabled.
Note: Bookmarks are supported in a 3D Scene only if they come from a WebMap or are provided manually. Presentation provides a similar experience for WebScenes.
- See also
Demo
Properties
| Property | Attribute | Type |
|---|---|---|
autoDestroyDisabled | auto-destroy-disabled | boolean |
bookmarks | | Collection<Bookmark> |
closedreflected | closed | boolean |
defaultCreateOptions | | BookmarkOptions |
defaultEditOptions | | BookmarkOptions |
disabled | disabled | boolean |
dragEnabled | drag-enabled | boolean |
filterPlaceholder | filter-placeholder | string |
filterText | filter-text | string |
goToOverride | | (((view: MapView | SceneView, goToParameters: GoToParameters) => void)) |
headingLevel | heading-level | 1 | 2 | 3 | 4 | 5 | 6 |
hideFlow | hide-flow | boolean |
hideThumbnail | hide-thumbnail | boolean |
hideTime | hide-time | boolean |
icon | icon | string |
label | label | string |
messageOverrides | | Record<string, unknown> |
positiondeprecatedreflected | position | "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing" |
referenceElement | reference-element | HTMLArcgisLinkChartElement | HTMLArcgisMapElement | HTMLArcgisSceneElement | string |
showAddBookmarkButton | show-add-bookmark-button | boolean |
showCloseButton | show-close-button | boolean |
showCollapseButton | show-collapse-button | boolean |
showEditBookmarkButton | show-edit-bookmark-button | boolean |
showFilter | show-filter | boolean |
showHeading | show-heading | boolean |
statereadonlyreflected | state | "loading" | "ready" |
timeDisabled | time-disabled | boolean |
view | | MapView | SceneView |
autoDestroyDisabled
autoDestroyDisabled: booleanIf true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporarily hide it. If this is set, make sure to call the destroy method when you are done to prevent memory leaks.
- Attribute
- auto-destroy-disabled
- Default value
- false
bookmarks
bookmarks: Collection<Bookmark>A collection of Bookmarks. These are typically defined inside of a WebMap, but can also be defined manually, as shown in the code snippet below.
Example
const bookmarksElement = document.querySelector("arcgis-bookmarks");
// define bookmarks manually
bookmarksElement.bookmarks = [
new Bookmark({
name: "Angeles National Forest",
viewpoint: {
targetGeometry: {
type: "extent",
spatialReference: {
wkid: 102100
},
xmin: -13139131.948889678,
ymin: 4047767.23531948,
xmax: -13092887.54677721,
ymax: 4090610.189673263
}
}
}),
new Bookmark({
name: "Crystal Lake",
viewpoint: {
targetGeometry: {
type: "extent",
spatialReference: {
wkid: 102100
},
xmin: -13125852.551697943,
ymin: 4066904.1101411926,
xmax: -13114291.451169826,
ymax: 4077614.8487296384
},
rotation: 90
}
})
];closed
closed: booleanIndicates whether a component is closed. When true, the component will be hidden.
- Attribute
- closed
- Default value
- false
defaultCreateOptions
defaultCreateOptions: BookmarkOptionsSpecifies how new bookmarks will be created if showAddBookmarkButton is set to true.
Can be used to enable or disable taking screenshots or capturing the bookmark's viewpoint based on the current
view when a bookmark is created. See BookmarkOptions
for the full list of options.
Example
const bookmarksElement = document.querySelector("arcgis-bookmarks");
bookmarksElement.showAddBookmarkButton = true;
bookmarksElement.defaultCreateOptions = {
// whenever a new bookmark is created, a 100x100 px
// screenshot of the view will be taken and the rotation, scale, and extent
// of the view will not be set as the viewpoint of the new bookmark
takeScreenshot: true,
captureViewpoint: false,
captureTimeExtent: false, // the time extent will not be saved in the bookmark
screenshotSettings: {
width: 100,
height: 100
}
};defaultEditOptions
defaultEditOptions: BookmarkOptionsSpecifies how bookmarks will be edited, if showEditBookmarkButton is set to true.
Can be used to enable or disable taking screenshots or capturing the bookmark's viewpoint based on the current
view when a bookmark is edited. See BookmarkOptions
for the full list of options.
disabled
disabled: booleanWhen true, the component is visually withdrawn and cannot be interacted with.
- Attribute
- disabled
- Default value
- false
dragEnabled
dragEnabled: booleanIndicates if a Bookmark is able to be dragged in order to update its position in the list.
- Attribute
- drag-enabled
- Default value
- false
filterPlaceholder
filterPlaceholder: stringDefines the text used as a placeholder when showFilter is set to true.
- Attribute
- filter-placeholder
- Default value
- ""
filterText
filterText: stringDefines the text used to filter the bookmarks when showFilter is set to true.
- Attribute
- filter-text
- Default value
- ""
goToOverride
goToOverride: (((view: MapView | SceneView, goToParameters: GoToParameters) => void))This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
headingLevel
headingLevel: 1 | 2 | 3 | 4 | 5 | 6Indicates the heading level to use for the message "No bookmarks" when no bookmarks
are available. By default, this message is rendered
as a level 2 heading (e.g. <h2>No bookmarks</h2>). Depending on the component's placement
in your app, you may need to adjust this heading for proper semantics. This is
important for meeting accessibility standards.
- See also
Example
// "No bookmarks" will render as an <h3>
bookmarksElement.headingLevel = 3;- Attribute
- heading-level
- Default value
- 2
hideFlow
hideFlow: booleanDetermines whether the component should be rendered within its built-in flow component.
- Attribute
- hide-flow
- Default value
- false
hideThumbnail
hideThumbnail: booleanIndicates whether the thumbnail associated with the bookmark is hidden.
- Attribute
- hide-thumbnail
- Default value
- false
hideTime
hideTime: booleanIndicates whether the time (h:m:s) displayed next to the date is hidden if the bookmark has a time extent defined.
- Attribute
- hide-time
- Default value
- false
icon
icon: stringIcon which represents the component. Typically used when the component is controlled by another component (e.g. by the Expand component).
- See also
- Attribute
- icon
- Default value
- "bookmark"
messageOverrides
messageOverrides: Record<string, unknown>Replace localized message strings with your own strings.
Note: Individual message keys may change between releases.
position
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"slot instead.- Attribute
- position
referenceElement
referenceElement: HTMLArcgisLinkChartElement | HTMLArcgisMapElement | HTMLArcgisSceneElement | stringBy assigning the id attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.
- Attribute
- reference-element
showAddBookmarkButton
showAddBookmarkButton: booleanIndicates whether to display the button to add a new bookmark.
- Attribute
- show-add-bookmark-button
- Default value
- false
showCloseButton
showCloseButton: booleanIndicates whether to display the close button.
- Attribute
- show-close-button
- Default value
- false
showCollapseButton
showCollapseButton: booleanIndicates whether to display the collapse button.
- Attribute
- show-collapse-button
- Default value
- false
showEditBookmarkButton
showEditBookmarkButton: booleanIndicates whether to display the button to edit a bookmark.
- Attribute
- show-edit-bookmark-button
- Default value
- false
showFilter
showFilter: booleanIndicates whether to display the bookmark filter.
- Attribute
- show-filter
- Default value
- false
showHeading
showHeading: booleanIndicates whether to display the heading.
- Attribute
- show-heading
- Default value
- false
state
state: "loading" | "ready"The current state of the component.
- Attribute
- state
- Default value
- "ready"
timeDisabled
timeDisabled: booleanIndicates whether to disable the time capability of the Bookmarks component.
- Attribute
- time-disabled
- Default value
- false
view
The view associated with the component.
Note: The recommended approach is to fully migrate applications to use map and scene components and avoid using MapView and SceneView directly. However, if you are migrating a large application from widgets to components, you might prefer a more gradual transition. To support this use case, the SDK includes this
viewproperty which connects a component to a MapView or SceneView. Ultimately, once migration is complete, the Bookmarks component will be associated with a map or scene component rather than using theviewproperty.
Methods
| Method | Signature |
|---|---|
componentOnReady | componentOnReady(): Promise<void> |
destroy | destroy(): Promise<void> |
goTo | goTo(bookmark: __esri.Bookmark): Promise<void> |
componentOnReady
componentOnReady(): Promise<void>Create a promise that resolves once component is fully loaded.
Example
const arcgisBookmarks = document.querySelector("arcgis-bookmarks");
document.body.append(arcgisBookmarks);
await arcgisBookmarks.componentOnReady();
console.log("arcgis-bookmarks is ready to go!");- Returns
- Promise<void>
goTo
goTo(bookmark: __esri.Bookmark): Promise<void>Zoom to a specific bookmark.
Parameters
| Parameter | Type | Optional? |
|---|---|---|
| bookmark | Bookmark |
- Returns
- Promise<void>
Events
| Event | Type |
|---|---|
arcgisBookmarkEdit | CustomEvent<BookmarksBookmarkEditEvent> |
arcgisBookmarkSelect | CustomEvent<BookmarksBookmarkSelectEvent> |
arcgisClose | CustomEvent<void> |
arcgisPropertyChange | CustomEvent<{ name: "state"; }> |
arcgisReady | CustomEvent<void> |
arcgisBookmarkEdit
arcgisBookmarkEdit: CustomEvent<BookmarksBookmarkEditEvent>Fires when a Bookmark is edited.
Example
// once an edit has been made, enable the "Save Webmap" button
// to allow the user to save their changes
bookmarksElement.addEventListener("arcgisBookmarkEdit", (event) => {
saveBtn.disabled = false;
});arcgisBookmarkSelect
arcgisBookmarkSelect: CustomEvent<BookmarksBookmarkSelectEvent>Fires when a Bookmark is selected.
Example
<arcgis-expand expanded>
<arcgis-bookmarks></arcgis-bookmarks>
</arcgis-expand>const bookmarksElement = document.querySelector("arcgis-bookmarks");
const expandElement = document.querySelector("arcgis-expand");
// collapses the associated Expand component
// when a bookmark is selected
bookmarksElement.addEventListener("arcgisBookmarkSelect", (event) => {
expandElement.expanded = false;
});arcgisClose
arcgisClose: CustomEvent<void>Emitted when the component's close button is clicked.
arcgisPropertyChange
arcgisPropertyChange: CustomEvent<{ name: "state"; }>Emitted when the value of a property is changed. Use this to listen to changes to properties.
arcgisReady
arcgisReady: CustomEvent<void>Emitted when the component associated with a map or scene view is ready to be interacted with.