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?
Solved! Go to Solution.
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.
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).
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.
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.)
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.
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.
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).