[GIS] Saving Bookmarks between sessions using ArcGIS API for JavaScript

arcgis-javascript-apibookmarks

The ArcGIS Server JavaScript API contains a Bookmark dijit which allows users to add and delete bookmarks. These are not persisted between sessions, but are reset each time the page refreshes.

Has anyone written code which saves the bookmarks between sessions, and which they're willing to share?

Failing that, does anyone have any pointers as to how you'd go about writing this functionality?

Presumably you would need to save each BookmarkItem to a cookie and read them in again when the page loaded – are there any samples I can use as a starting point?

Ideally this would be tied to a user, but more realistically it could be tied to a browser only.

Best Answer

Yes, there's a sample in the SDK docs that shows this called Store Bookmarks Client Side:

The bookmarks widget does not natively persist bookmarks created by a user. This sample shows how to store user created bookmarks client side. When bookmarks are created, the app tries to store them in local storage. If local storage is not available, the app falls back to using a cookie.

Related Question