@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
195 lines (189 loc) • 8.93 kB
TypeScript
import type Collection from "../../core/Collection.js";
import type Bookmark from "../../webmap/Bookmark.js";
import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";
import type { EventedAccessor } from "../../core/Evented.js";
import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
import type { BookmarkProperties } from "../../webmap/Bookmark.js";
import type { BookmarkOptions, BookmarksCapabilities } from "./types.js";
import type { GoTo, GoToProperties } from "../support/GoTo.js";
export interface BookmarksViewModelProperties extends GoToProperties, Partial<Pick<BookmarksViewModel, "capabilities" | "view">> {
/** A collection of [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/)s. */
bookmarks?: ReadonlyArrayOrCollection<BookmarkProperties> | null;
/**
* 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/types/#BookmarkOptions)
* for the full list of options.
*
* @since 4.18
*/
defaultCreateOptions?: Partial<BookmarkOptions>;
/**
* 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/types/#BookmarkOptions)
* for the full list of options.
*
* @since 4.18
*/
defaultEditOptions?: Partial<BookmarkOptions>;
}
export type BookmarksViewModelState = "ready" | "loading";
export interface BookmarksViewModelEvents {
/**
* Fires when a [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/) is edited.
*
* @since 4.17
* @example
* // once an edit has been made, enable the "Save Webmap" button
* // to allow the user to save their changes
* bookmarksWidget.on("bookmark-edit", function(event){
* saveBtn.disabled = false;
* }
*/
"bookmark-edit": BookmarksViewModelBookmarkEditEvent;
/**
* Fires when a [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/) is selected.
*
* @since 4.17
* @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 bookmark
* bookmarksWidget.on("bookmark-select", function(event){
* bookmarksExpand.expanded = false;
* });
*/
"bookmark-select": BookmarksViewModelBookmarkSelectEvent;
}
export interface BookmarksViewModelBookmarkEditEvent {
/** The edited bookmark. */
bookmark: Bookmark;
}
export interface BookmarksViewModelBookmarkSelectEvent {
/** The bookmark selected by the user. */
bookmark: Bookmark;
}
/**
* Provides the logic for the [Bookmarks](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/) widget.
*
* @deprecated since version 5.0. Use the [Bookmarks component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-bookmarks/) directly instead.
* @since 4.8
* @see [Bookmarks](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/) widget - _Deprecated since 4.34. Use the [Bookmarks component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-bookmarks/) instead._
* @see [Bookmarks component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-bookmarks/)
* @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
*/
export default class BookmarksViewModel extends BookmarksViewModelSuperclass {
/**
* @deprecated
* Do not directly reference this property.
* Use EventNames and EventTypes helpers from \@arcgis/core/Evented
*/
"@eventTypes": BookmarksViewModelEvents;
constructor(properties?: BookmarksViewModelProperties);
/**
* The [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/) that is being navigated to.
*
* @since 4.9
*/
get activeBookmark(): Bookmark | null | undefined;
/** A collection of [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/)s. */
get bookmarks(): Collection<Bookmark>;
set bookmarks(value: ReadonlyArrayOrCollection<BookmarkProperties> | null | undefined);
/**
* Defines the capabilities of the widget. This property can be used to enable or disable the time capability of the Bookmarks widget.
*
* @since 4.27
* @example
* const bookmarksVM = new BookmarksViewModel({
* view: view,
* capabilities: {
* time: false // disables all time capability in the Bookmarks widget
* }
* });
*/
accessor capabilities: BookmarksCapabilities;
/**
* 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/types/#BookmarkOptions)
* for the full list of options.
*
* @since 4.18
*/
get defaultCreateOptions(): BookmarkOptions;
set defaultCreateOptions(value: Partial<BookmarkOptions>);
/**
* 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/types/#BookmarkOptions)
* for the full list of options.
*
* @since 4.18
*/
get defaultEditOptions(): BookmarkOptions;
set defaultEditOptions(value: Partial<BookmarkOptions>);
/**
* The view model's state.
*
* @default "ready"
*/
get state(): BookmarksViewModelState;
/** The view from which the widget will operate. */
accessor view: MapViewOrSceneView | null | undefined;
/**
* Creates a new bookmark from the [defaultCreateOptions](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/BookmarksViewModel/#defaultCreateOptions), unless otherwise specified.
*
* @param 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.
* @returns When resolved, returns the newly created [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/).
* @since 4.13
* @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);
* });
*/
createBookmark(options?: BookmarkOptions): Promise<Bookmark>;
/**
* Edits the given bookmark.
*
* @param bookmark - The bookmark to be edited.
* @param 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](https://developers.arcgis.com/javascript/latest/references/core/widgets/Bookmarks/BookmarksViewModel/#defaultEditOptions) will be used.
* @returns When resolved, returns the edited [Bookmark](https://developers.arcgis.com/javascript/latest/references/core/webmap/Bookmark/).
* @since 4.17
* @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);
* })
*/
editBookmark(bookmark: Bookmark | null | undefined, options?: BookmarkOptions): Promise<Bookmark | null | undefined>;
/**
* Zoom to a specific bookmark.
*
* @param bookmark - The bookmark to zoom to.
* @returns Resolves after the animation to specified bookmark finishes.
*/
goTo(bookmark: Bookmark): Promise<any>;
}
declare const BookmarksViewModelSuperclass: typeof EventedAccessor & typeof GoTo