require(["esri/widgets/Bookmarks/BookmarksViewModel"], (BookmarksViewModel) => { /* code goes here */ });
import BookmarksViewModel from "@arcgis/core/widgets/Bookmarks/BookmarksViewModel.js";
esri/widgets/Bookmarks/BookmarksViewModel
Provides the logic for the Bookmarks widget.
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The Bookmark that is being navigated to. | BookmarksViewModel | ||
A collection of Bookmarks. | BookmarksViewModel | ||
Defines the capabilities of the widget. | BookmarksViewModel | ||
The name of the class. | Accessor | ||
Specifies how new bookmarks will be created. | BookmarksViewModel | ||
Specifies how bookmarks will be edited. | BookmarksViewModel | ||
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods. | BookmarksViewModel | ||
The view model's state. | BookmarksViewModel | ||
The view from which the widget will operate. | BookmarksViewModel |
Property Details
-
bookmarks
bookmarks Collection<Bookmark>
-
A collection of Bookmarks.
-
capabilities
capabilities BookmarksCapabilities
Since: ArcGIS Maps SDK for JavaScript 4.27BookmarksViewModel since 4.8, capabilities added at 4.27. -
Defines the capabilities of the widget. This property can be used to enable or disable the time capability of the Bookmarks widget.
Exampleconst bookmarksVM = new BookmarksViewModel({ view: view, capabilities: { time: false // disables all time capability in the Bookmarks widget } });
-
defaultCreateOptions
defaultCreateOptions BookmarkOptions
Since: ArcGIS Maps SDK for JavaScript 4.18BookmarksViewModel since 4.8, defaultCreateOptions added at 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
defaultEditOptions BookmarkOptions
Since: ArcGIS Maps SDK for JavaScript 4.18BookmarksViewModel since 4.8, defaultEditOptions added at 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 GoToOverride
-
This function provides the ability to override either the MapView goTo() or SceneView goTo() methods.
- See also
-
- esri/views/MapView#goTo
- SceneView
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
state Stringreadonly
-
The view model's state.
Possible Values:"loading" |"ready"
- Default Value:"ready"
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Promise<Bookmark> | Creates a new bookmark from the defaultCreateOptions, unless otherwise specified. | BookmarksViewModel | |
Promise<Bookmark> | Edits the given bookmark. | BookmarksViewModel | |
Promise | Zoom to a specific bookmark. | BookmarksViewModel | |
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 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 } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey 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
createBookmark(options){Promise<Bookmark>}
Since: ArcGIS Maps SDK for JavaScript 4.13BookmarksViewModel since 4.8, createBookmark added at 4.13. -
Creates a new bookmark from the defaultCreateOptions, unless otherwise specified.
Parameteroptions BookmarkOptionsoptionalSpecifies how new bookmarks will be created. Can be used to enable/disable taking screenshots or capturing the extent when a new bookmark is added.
ReturnsExample// 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
editBookmark(bookmark, options){Promise<Bookmark>}
Since: ArcGIS Maps SDK for JavaScript 4.17BookmarksViewModel since 4.8, editBookmark added at 4.17. -
Edits the given bookmark.
Parametersbookmark BookmarkThe bookmark to be edited.
options BookmarkOptionsoptionalSpecifies 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.
ReturnsExampleconst 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); })
-
Zoom to a specific bookmark.
Parameterbookmark BookmarkThe bookmark to zoom to.
ReturnsType Description Promise Resolves after the animation to specified bookmark finishes.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType 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"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
Type Definitions
-
BookmarkOptions
BookmarkOptions Object
-
Specifies how bookmarks will be created or modified.
- Properties
-
takeScreenshot Boolean
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 BooleanSince 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 BooleanSince 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 BooleanSince 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 BooleanSince 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 ObjectAn object that specifies the settings of the screenshot that will be used to create the bookmark's thumbnail.
- Specification
-
width Number
The width (in pixels) of the screenshot. Default is
128px
.height NumberThe height (in pixels) of the screenshot. Default is
128px
.area ObjectUsed to take a screenshot of a subregion of the view. Defaults to the whole view.
optional An optional list of layers to be included in the screenshot.
-
BookmarksCapabilities
BookmarksCapabilities Object
-
Specifies the abilities for the Bookmarks widget.
- Property
-
time Boolean
Indicates whether the time capability is enabled in the Bookmarks widget. Default is
true
. Whenfalse
, the timeExtent of a bookmark will not be visible or editable. Any newly created bookmarks will not capture the time extent.