MapView.bookmarks in JSAPI 4.x?

2610
7
Jump to solution
03-17-2020 10:12 AM
EthanBodin1
New Contributor III

In the 4.x version of ArcGIS API for JavaScript, the Bookmarks widget and bookmarks property apply only to a WebView. In 3.x, bookmarks could be used without a web map. Will Bookmarks be available for MapViews in 4.x?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

It displays a list of bookmarks, which typically are defined inside the WebMap

Yes the easiest way to use the bookmark widget is to use a webmap that has bookmarks defined in it, but that does not prevent you from creating your own bookmarks collection manually in code and setting the Bookmarks widget bookmarks property to that collection. I have not seen a sample for this because the normal route is to use a webmap.

View solution in original post

0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

What is a WebView?... In 4.x the Bookmark widget applies to 2D maps only (i.e. MapView). They currently do not work for SceneViews (as this is a know limitation).

0 Kudos
EthanBodin1
New Contributor III

Thank you for the question, which caused me to review and find two mistakes in my post. A less than thorough reading of API docs and sample code led me to believe the widget's view needed to derive from a WebMap (not a WebView, which I made up). I will give it a go.

EthanBodin1
New Contributor III

The WebStyleSymbol (2D) sample has the Bookmarks widget working with an esri/Map in place of esri/WebMap. The key is to initialize the Bookmark widget's bookmarks with an array of Bookmark objects; without that adding a bookmark fails silently.

I still claim the documentation implies WebMap is central to bookmarks functionality (Searching the API for "bookmarks", it looks like WebMap is at the root of Bookmarks. The only Bookmark class is esri/webmap/Bookmark. The only classes with a bookmarks property are the widget and WebMap. The Bookmark class and Bookmarks widget API pages both start off with "typically are defined inside the WebMap", but don't mention any other way to define them, and the sample linked from those pages uses a WebMap.)

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

It displays a list of bookmarks, which typically are defined inside the WebMap

Yes the easiest way to use the bookmark widget is to use a webmap that has bookmarks defined in it, but that does not prevent you from creating your own bookmarks collection manually in code and setting the Bookmarks widget bookmarks property to that collection. I have not seen a sample for this because the normal route is to use a webmap.

0 Kudos
DianeBird
New Contributor III

Is it possible to have both user created bookmarks in the webmap and manually coded bookmarks appearing in the same list when the widget opens? I seem to be able to do one or the other, but not both.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Diane,

   I have not tested it but it would seem logical that you can just add to the bookmarks collection object (which already has the webmaps bookmarks).

0 Kudos
DianeBird
New Contributor III

Yes - I was able to add it to the code as follows:

It works perfectly, and I can still add new bookmarks to the list.