BookmarksViewModel

AMD: require(["esri/widgets/Bookmarks/BookmarksViewModel"], (BookmarksViewModel) => { /* code goes here */ });
ESM: import BookmarksViewModel from "@arcgis/core/widgets/Bookmarks/BookmarksViewModel";
Class: esri/widgets/Bookmarks/BookmarksViewModel
Inheritance: BookmarksViewModel Accessor
Since: ArcGIS API for JavaScript 4.8

Provides the logic for the Bookmarks widget.

See also

Constructors

new BookmarksViewModel(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class
Abilities

Defines the abilities of the widget.

more details
BookmarksViewModel
Bookmark

The Bookmark that is being navigated to.

more details
BookmarksViewModel
Collection<Bookmark>

A collection of Bookmarks.

more details
BookmarksViewModel
String

The name of the class.

more details
Accessor
BookmarkOptions

Specifies how new bookmarks will be created.

more details
BookmarksViewModel
BookmarkOptions

Specifies how bookmarks will be edited.

more details
BookmarksViewModel
GoToOverride

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

more details
BookmarksViewModel
String

The view model's state.

more details
BookmarksViewModel
MapView|SceneView

The view from which the widget will operate.

more details
BookmarksViewModel

Property Details

abilities Abilities
Since: ArcGIS API for JavaScript 4.22

Defines the abilities of the widget. This property can be used to enable or disable the time ability of the Bookmarks widget.

Example
const bookmarksVM = new BookmarksViewModel({
  view: view,
  abilities: {
     time: false // disables all time ability in the Bookmarks widget
  }
});
activeBookmark Bookmarkreadonly
Since: ArcGIS API for JavaScript 4.9

The Bookmark that is being navigated to.

bookmarks Collection<Bookmark>

A collection of Bookmarks.

declaredClass Stringreadonly inherited

The name of the class. The declared class name is formatted as esri.folder.className.

defaultCreateOptions BookmarkOptions
Since: ArcGIS API 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 BookmarkOptions
Since: ArcGIS API 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 GoToOverride

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

See also
Example
// The following snippet uses the Search widget 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);
};
state Stringreadonly

The view model's state.

Possible Values:"loading"|"ready"

Default Value:ready

The view from which the widget will operate.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

more details
Accessor
Promise<Bookmark>

Creates a new bookmark from the defaultCreateOptions, unless otherwise specified.

more details
BookmarksViewModel
Promise<Bookmark>

Edits the given bookmark.

more details
BookmarksViewModel
Promise

Zoom to a specific bookmark.

more details
BookmarksViewModel
Boolean

Returns true if a named group of handles exist.

more details
Accessor

Removes a group of handles owned by the object.

more details
Accessor

Method Details

addHandles(handleOrHandles, groupKey)inherited
Since: ArcGIS API for JavaScript 4.25

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

// Handle gets removed when the object is destroyed.
this.addHandles(handle);
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

createBookmark(options){Promise<Bookmark>}
Since: ArcGIS API for JavaScript 4.13

Creates a new bookmark from the defaultCreateOptions, unless otherwise specified.

Parameter
options BookmarkOptions
optional

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.

Returns
Type Description
Promise<Bookmark> When resolved, returns the newly created Bookmark.
Example
// Creates new bookmark from current view extent
viewModel.createBookmark().then(function(bookmark){
   // Give the bookmark a name
   bookmark.name = "New Bookmark";
   // Add to bookmarks list
   viewModel.bookmarks.add(bookmark);
});
editBookmark(bookmark, options){Promise<Bookmark>}
Since: ArcGIS API for JavaScript 4.17

Edits the given bookmark.

Parameters
bookmark Bookmark

The bookmark to be edited.

options BookmarkOptions
optional

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.

Returns
Type Description
Promise<Bookmark> When resolved, returns the edited Bookmark.
Example
const options = {
  takeScreenshot: false,
  captureViewpoint: true
};

// update the given bookmark's viewpoint without taking a new screenshot
viewModel.editBookmark(bookmark, options).then(function(editedBookmark){
   // the edited bookmark's viewpoint should now match the current view
   console.log(editedBookmark.viewpoint);
   console.log(view.viewpoint);
})
goTo(bookmark){Promise}

Zoom to a specific bookmark.

Parameter
bookmark Bookmark

The bookmark to zoom to.

Returns
Type Description
Promise Resolves after the animation to specified bookmark finishes.
hasHandles(groupKey){Boolean}inherited
Since: ArcGIS API for JavaScript 4.25

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}
removeHandles(groupKey)inherited
Since: ArcGIS API for JavaScript 4.25

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Type Definitions

Abilities Object

Specifies the abilities for the Bookmarks widget.

Property
time Boolean
optional

Indicates whether the time ability is enabled in the Bookmarks widget. Default is true. When false, the timeExtent of a bookmark will not be visible or editable. Any newly created bookmarks will not capture the time extent.

BookmarkOptions Object

Specifies how bookmarks will be created or modified.

Properties
takeScreenshot Boolean
optional

Indicates whether a screenshot is taken when a new bookmark is created. The screenshot will be set as the thumbnail in the newly created bookmark. Default is true.

captureViewpoint Boolean
optional

Since 4.17 Indicates whether the viewpoint of the current view will become the viewpoint of a newly created or modified bookmark. Default is true.

captureRotation Boolean
optional

Since 4.17 Indicates whether the rotation of the current view will be saved in the viewpoint of a newly created or modified bookmark. Default is true.

captureScale Boolean
optional

Since 4.17 Indicates whether the scale of the current view will be saved in the viewpoint of a newly created or modified bookmark. Default is true.

captureTimeExtent Boolean
optional

Since 4.22 Indicates whether the time extent of the current view will be saved in the timeExtent of a newly created or modified bookmark. Default is true.

screenshotSettings Object
optional

An object that specifies the settings of the screenshot that will be used to create the bookmark's thumbnail.

Specification
width Number
optional

The width (in pixels) of the screenshot. Default is 128px.

height Number
optional

The height (in pixels) of the screenshot. Default is 128px.

area Object
optional

Used to take a screenshot of a subregion of the view. Defaults to the whole view.

Specification
x Number
optional

The x value of the screenshot area.

y Number
optional

The y value of the screenshot area.

width Number
optional

The width of the screenshot area.

height Number
optional

The height of the screenshot area.

layers Layer[]
optional

An optional list of layers to be included in the screenshot.

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