Bookmarks Widget Displays a list of bookmarks that are only defined in the web map? Can it work with other objects also?
And another separate question. Can I remove or add items to the bookmark using code? Are there remove or add methods to use dynamically in my program? Or is it only possible through the user interface?
For example
const bookmarks = new Bookmarks({});
bookmarks.Add(element) or bookmarks.Delete(element)
Thanks!
This is all built in to the Bookmarks widget.
https://developers.arcgis.com/javascript/latest/sample-code/widgets-bookmarks/
You could even save them to localStorage if you don't want to save them back to the WebMap (outdated)
https://codepen.io/odoe/pen/QxrEVX?editors=0010
This samples is better for local adding of bookmarks
https://developers.arcgis.com/javascript/latest/sample-code/webstylesymbol-2d/
Thank you very much!
The second example has what I asked if it is possible to add an element. It's just not very clear what means extent in bookmark?
As for the first example, I didn't really ask about what is built into the interface. This part didn't interest me at all. I was wondering if I can affect objects through the code, generally remove elements and add others, for example, use it for other objects by writing different code. And I also asked if it only works with a webmap? Is it possible for example to use another object, say WMSLayer? Which we can also paste into Map and which we can paste into MapView or, as I asked earlier, it is only built into WebMap? In all examples, in all projects anf files on this site only WEBMAP with Bookmarks. I tried with other Map objects, it doesn't work. That's why I'm asking.
It only works for a WebMap, not sure how you would use Bookmarks for layers.
This is a better sample for adding to the Bookmarks manually
https://developers.arcgis.com/javascript/latest/sample-code/webstylesymbol-2d/
In angular not work.
Error: src/app/app.component.ts:74:33 - error TS2345: Argument of type '{ extent: Extent; name: string; }' is not assignable to parameter of type 'Bookmark'.
Type '{ extent: Extent; name: string; }' is missing the following properties from type 'Bookmark': thumbnail, timeExtent, viewpoint, destroyed, and 9 more.
74 bookmarks.bookmarks.add(bookmark);
That demo was old, check the doc, it uses a viewpoint property now
const bookmark = new Bookmark( {
name: name
});
bookmarks.bookmarks.add(bookmark);
import Bookmark from "@arcgis/core/webmap/Bookmark";
ok.
Very easy can to use bookmarks, for example, to fill them in at the beginning as I actually want. And then just write function for any click or change event and just change sublayers by selected name from bookmarks.
Thank you very much! 😊