Bookmarks widget what is possible and what is not? Add and Delete Items......

740
9
08-29-2022 07:00 AM
DimaY
by
New Contributor

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!

0 Kudos
9 Replies
ReneRubalcava
Frequent Contributor

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/

0 Kudos
DimaY
by
New Contributor

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. 



0 Kudos
DimaY
by
New Contributor

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);

0 Kudos
ReneRubalcava
Frequent Contributor

That demo was old, check the doc, it uses a viewpoint property now

0 Kudos
DimaY
by
New Contributor

const bookmark = new Bookmark( {
name: name
});
bookmarks.bookmarks.add(bookmark);

import Bookmark from "@arcgis/core/webmap/Bookmark";

ok. 

0 Kudos
DimaY
by
New Contributor

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. 

0 Kudos
DimaY
by
New Contributor

Thank you very much! 😊

0 Kudos
MohammedZaki
New Contributor III

Hello @DimaY , did it work in Angular? adding a bookmark?

It gives me this error :

MohammedZaki_0-1671894259338.png

 

0 Kudos