import BookmarksViewModel from "@arcgis/core/widgets/Bookmarks/BookmarksViewModel.js";const BookmarksViewModel = await $arcgis.import("@arcgis/core/widgets/Bookmarks/BookmarksViewModel.js");- Inheritance
- BookmarksViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.8
Provides the logic for the Bookmarks widget.
- See also
Bookmarks widget - Deprecated since 4.34. Use the Bookmarks component instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| readonly | | |
| | ||
| | ||
| readonly inherited | ||
| | ||
| | ||
| inherited | ||
| readonly | | |
| |
capabilities
- Since
- ArcGIS Maps SDK for JavaScript 4.27
Defines the capabilities of the widget. This property can be used to enable or disable the time capability of the Bookmarks widget.
- Example
- const bookmarksVM = new BookmarksViewModel({view: view,capabilities: {time: false // disables all time capability in the Bookmarks widget}});
defaultCreateOptions
- Type
- BookmarkOptions
- Since
- ArcGIS Maps SDK for JavaScript 4.18
Specifies how new bookmarks will be created. 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.
defaultEditOptions
- Type
- BookmarkOptions
- Since
- ArcGIS Maps SDK for JavaScript 4.18
Specifies how bookmarks will be edited. 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.
goToOverride
- Type
- GoToOverride | null | undefined
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
- See also
- Example
- // The following snippet uses Search but can be applied to any// widgets that support the goToOverride property.search.goToOverride = function(view, goToParams) {goToParams.options = {duration: updatedDuration};return view.goTo(goToParams.target, goToParams.options);};
view
- Type
- MapViewOrSceneView | null | undefined
The view from which the widget will operate.
Methods
| Method | Signature | Class |
|---|---|---|
| createBookmark(options?: BookmarkOptions): Promise<Bookmark> | | |
| editBookmark(bookmark: Bookmark | null | undefined, options?: BookmarkOptions): Promise<Bookmark | null | undefined> | | |
| inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
| goTo(bookmark: Bookmark): Promise<any> | | |
| inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
| inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle |
createBookmark
- Signature
-
createBookmark (options?: BookmarkOptions): Promise<Bookmark>
- Since
- ArcGIS Maps SDK for JavaScript 4.13
Creates a new bookmark from the defaultCreateOptions, unless otherwise specified.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| options | Specifies how new bookmarks will be created. Can be used to enable/disable taking screenshots or capturing the extent when a new bookmark is added. | |
- Example
- // Creates new bookmark from current view extentviewModel.createBookmark().then(function(bookmark){// Give the bookmark a namebookmark.name = "New Bookmark";// Add to bookmarks listviewModel.bookmarks.add(bookmark);});
editBookmark
- Signature
-
editBookmark (bookmark: Bookmark | null | undefined, options?: BookmarkOptions): Promise<Bookmark | null | undefined>
- Since
- ArcGIS Maps SDK for JavaScript 4.17
Edits the given bookmark.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| bookmark | The bookmark to be edited. | | |
| options | Specifies how bookmarks will be edited. Can be used to enable/disable taking screenshots or capturing the extent when a bookmark is edited. If not specified, the defaultEditOptions will be used. | |
- Example
- const options = {takeScreenshot: false,captureViewpoint: true};// update the given bookmark's viewpoint without taking a new screenshotviewModel.editBookmark(bookmark, options).then(function(editedBookmark){// the edited bookmark's viewpoint should now match the current viewconsole.log(editedBookmark.viewpoint);console.log(view.viewpoint);})
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | An event or an array of events to listen for. | |
| listener | EventedCallback<this["@eventTypes"][Type]> | The function to call when the event fires. | |
- Returns
- ResourceHandle
Returns an event handler with a
remove()method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event.
- Example
- view.on("click", function(event){// event is the event handle returned after the event fires.console.log(event.mapPoint);});
Events
bookmark-edit
bookmark-edit: CustomEvent<BookmarksViewModelBookmarkEditEvent> - Since
- ArcGIS Maps SDK for JavaScript 4.17
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 changesbookmarksWidget.on("bookmark-edit", function(event){saveBtn.disabled = false;}
bookmark-select
bookmark-select: CustomEvent<BookmarksViewModelBookmarkSelectEvent> - Since
- ArcGIS Maps SDK for JavaScript 4.17
Fires when a Bookmark is selected.
- Example
- const bookmarksWidget = new Bookmarks({view: view});const bookmarksExpand = new Expand({view: view,content: bookmarksWidget});view.ui.add(bookmarksExpand, "top-right");// collapses the associated Expand instance// when the user selects a bookmarkbookmarksWidget.on("bookmark-select", function(event){bookmarksExpand.expanded = false;});