How can I set the Bookmark widget to automatically close when a bookmark is selected

387
2
Jump to solution
12-09-2021 08:01 PM
WWUMap
by
New Contributor II

Hi, I've added the Bookmark widget and would like to automatically close when a user chooses a bookmark.  

Any suggestions?

thanks

~stefan (javascript beginner)

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
AnneFitz
Esri Contributor

Hi Stefan! You can watch for the "bookmark-select" event and then close the expand widget, like this:

const bookmarksWidget = new Bookmarks({
  view: view
});

const bookmarksExpand = new Expand({
  view: view,
  content: bookmarksWidget
});
view.ui.add(bookmarksExpand, "top-right");

// collapses the associated Expand instance
// when the user selects a bookmark
bookmarksWidget.on("bookmark-select", function(event){
  bookmarksExpand.expanded = false;
});

 

View solution in original post

0 Kudos
2 Replies
AnneFitz
Esri Contributor

Hi Stefan! You can watch for the "bookmark-select" event and then close the expand widget, like this:

const bookmarksWidget = new Bookmarks({
  view: view
});

const bookmarksExpand = new Expand({
  view: view,
  content: bookmarksWidget
});
view.ui.add(bookmarksExpand, "top-right");

// collapses the associated Expand instance
// when the user selects a bookmark
bookmarksWidget.on("bookmark-select", function(event){
  bookmarksExpand.expanded = false;
});

 

0 Kudos
WWUMap
by
New Contributor II

Thanks AnneFitz.  That works great!

0 Kudos