Skip to content

Bookmarks

ESM:
Use dark colors for code blocksCopy
1
import "@arcgis/map-components/components/arcgis-bookmarks";
CDN:
No specific import is needed for this component.
Since:ArcGIS Maps SDK for JavaScript 4.28

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

PropertyAttributeType
autoDestroyDisabledauto-destroy-disabledboolean
bookmarksCollection<Bookmark>
closed
reflected
closedboolean
defaultCreateOptionsBookmarkOptions
defaultEditOptionsBookmarkOptions
disableddisabledboolean
dragEnableddrag-enabledboolean
filterPlaceholderfilter-placeholderstring
filterTextfilter-textstring
goToOverride(((view: MapView | SceneView, goToParameters: GoToParameters) => void))
headingLevelheading-level1 | 2 | 3 | 4 | 5 | 6
hideFlowhide-flowboolean
hideThumbnailhide-thumbnailboolean
hideTimehide-timeboolean
iconiconstring
labellabelstring
messageOverridesRecord<string, unknown>
position
deprecatedreflected
position"bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
referenceElementreference-elementHTMLArcgisLinkChartElement | HTMLArcgisMapElement | HTMLArcgisSceneElement | string
showAddBookmarkButtonshow-add-bookmark-buttonboolean
showCloseButtonshow-close-buttonboolean
showCollapseButtonshow-collapse-buttonboolean
showEditBookmarkButtonshow-edit-bookmark-buttonboolean
showFiltershow-filterboolean
showHeadingshow-headingboolean
state
readonlyreflected
state"loading" | "ready"
timeDisabledtime-disabledboolean
viewMapView | SceneView

autoDestroyDisabled

Property
autoDestroyDisabled: boolean

If 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

Property
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
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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

reflected
Property
closed: boolean

Indicates whether a component is closed. When true, the component will be hidden.

Attribute
closed
Default value
false

defaultCreateOptions

Property
defaultCreateOptions: BookmarkOptions

Specifies 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
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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

Property
defaultEditOptions: BookmarkOptions

Specifies 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

Property
disabled: boolean

When true, the component is visually withdrawn and cannot be interacted with.

Attribute
disabled
Default value
false

dragEnabled

Property
dragEnabled: boolean
Since:ArcGIS Maps SDK for JavaScript 4.29Bookmarks since 4.28, dragEnabled added at 4.29.

Indicates if a Bookmark is able to be dragged in order to update its position in the list.

Attribute
drag-enabled
Default value
false

filterPlaceholder

Property
filterPlaceholder: string
Since:ArcGIS Maps SDK for JavaScript 4.29Bookmarks since 4.28, filterPlaceholder added at 4.29.

Defines the text used as a placeholder when showFilter is set to true.

Attribute
filter-placeholder
Default value
""

filterText

Property
filterText: string
Since:ArcGIS Maps SDK for JavaScript 4.29Bookmarks since 4.28, filterText added at 4.29.

Defines the text used to filter the bookmarks when showFilter is set to true.

Attribute
filter-text
Default value
""

goToOverride

Property
goToOverride: (((view: MapView | SceneView, goToParameters: GoToParameters) => void))

This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.

Read more...

headingLevel

Property
headingLevel: 1 | 2 | 3 | 4 | 5 | 6
Since:ArcGIS Maps SDK for JavaScript 4.34Bookmarks since 4.28, headingLevel added at 4.34.

Indicates 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
Use dark colors for code blocksCopy
1
2
// "No bookmarks" will render as an <h3>
bookmarksElement.headingLevel = 3;
Attribute
heading-level
Default value
2

hideFlow

Property
hideFlow: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, hideFlow added at 4.30.

Determines whether the component should be rendered within its built-in flow component.

Attribute
hide-flow
Default value
false

hideThumbnail

Property
hideThumbnail: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, hideThumbnail added at 4.30.

Indicates whether the thumbnail associated with the bookmark is hidden.

Attribute
hide-thumbnail
Default value
false

hideTime

Property
hideTime: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, hideTime added at 4.30.

Indicates 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

Property
icon: string

Icon 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"

label

Property
label: string

The component's default label.

Attribute
label

messageOverrides

Property
messageOverrides: Record<string, unknown>
Since:ArcGIS Maps SDK for JavaScript 4.34Bookmarks since 4.28, messageOverrides added at 4.34.

Replace localized message strings with your own strings.

Note: Individual message keys may change between releases.

position

deprecatedreflected
Property
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
Deprecatedsince 4.34, use slot instead.
Attribute
position

referenceElement

Property

By 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.

See also
Attribute
reference-element

showAddBookmarkButton

Property
showAddBookmarkButton: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, showAddBookmarkButton added at 4.30.

Indicates whether to display the button to add a new bookmark.

Attribute
show-add-bookmark-button
Default value
false

showCloseButton

Property
showCloseButton: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, showCloseButton added at 4.30.

Indicates whether to display the close button.

Attribute
show-close-button
Default value
false

showCollapseButton

Property
showCollapseButton: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, showCollapseButton added at 4.30.

Indicates whether to display the collapse button.

Attribute
show-collapse-button
Default value
false

showEditBookmarkButton

Property
showEditBookmarkButton: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, showEditBookmarkButton added at 4.30.

Indicates whether to display the button to edit a bookmark.

Attribute
show-edit-bookmark-button
Default value
false

showFilter

Property
showFilter: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, showFilter added at 4.30.

Indicates whether to display the bookmark filter.

Attribute
show-filter
Default value
false

showHeading

Property
showHeading: boolean
Since:ArcGIS Maps SDK for JavaScript 4.30Bookmarks since 4.28, showHeading added at 4.30.

Indicates whether to display the heading.

Attribute
show-heading
Default value
false

state

readonlyreflected
Property
state: "loading" | "ready"

The current state of the component.

Attribute
state
Default value
"ready"

timeDisabled

Property
timeDisabled: boolean
Since:ArcGIS Maps SDK for JavaScript 4.34Bookmarks since 4.28, timeDisabled added at 4.34.

Indicates whether to disable the time capability of the Bookmarks component.

Attribute
time-disabled
Default value
false

view

Property

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 view property 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 the view property.

Methods

MethodSignature
componentOnReadycomponentOnReady(): Promise<void>
destroydestroy(): Promise<void>
goTogoTo(bookmark: __esri.Bookmark): Promise<void>

componentOnReady

Method
componentOnReady(): Promise<void>

Create a promise that resolves once component is fully loaded.

Example
Use dark colors for code blocksCopy
1
2
3
4
const arcgisBookmarks = document.querySelector("arcgis-bookmarks");
document.body.append(arcgisBookmarks);
await arcgisBookmarks.componentOnReady();
console.log("arcgis-bookmarks is ready to go!");
Returns
Promise<void>

destroy

Method
destroy(): Promise<void>

Permanently destroy the component.

Returns
Promise<void>

goTo

Method
goTo(bookmark: __esri.Bookmark): Promise<void>
Since:ArcGIS Maps SDK for JavaScript 4.34Bookmarks since 4.28, goTo added at 4.34.

Zoom to a specific bookmark.

Parameters
ParameterTypeOptional?
bookmarkBookmark
Returns
Promise<void>

Events

EventType
arcgisBookmarkEditCustomEvent<BookmarksBookmarkEditEvent>
arcgisBookmarkSelectCustomEvent<BookmarksBookmarkSelectEvent>
arcgisCloseCustomEvent<void>
arcgisPropertyChangeCustomEvent<{ name: "state"; }>
arcgisReadyCustomEvent<void>

arcgisBookmarkEdit

Event
arcgisBookmarkEdit: CustomEvent<BookmarksBookmarkEditEvent>
Since:ArcGIS Maps SDK for JavaScript 4.34Bookmarks since 4.28, arcgisBookmarkEdit added at 4.34.

Fires when a Bookmark is edited.

Example
Use dark colors for code blocksCopy
1
2
3
4
5
// 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;
});
bubbles
composed
cancelable

arcgisBookmarkSelect

Event
arcgisBookmarkSelect: CustomEvent<BookmarksBookmarkSelectEvent>
Since:ArcGIS Maps SDK for JavaScript 4.34Bookmarks since 4.28, arcgisBookmarkSelect added at 4.34.

Fires when a Bookmark is selected.

Example
Use dark colors for code blocksCopy
1
2
3
<arcgis-expand expanded>
 <arcgis-bookmarks></arcgis-bookmarks>
</arcgis-expand>
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
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;
});
bubbles
composed
cancelable

arcgisClose

Event
arcgisClose: CustomEvent<void>

Emitted when the component's close button is clicked.

bubbles
composed
cancelable

arcgisPropertyChange

Event
arcgisPropertyChange: CustomEvent<{ name: "state"; }>

Emitted when the value of a property is changed. Use this to listen to changes to properties.

bubbles
composed
cancelable

arcgisReady

Event
arcgisReady: CustomEvent<void>

Emitted when the component associated with a map or scene view is ready to be interacted with.

bubbles
composed
cancelable

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.