Bookmarks Widget - v4.8

620
4
07-20-2018 02:16 PM
OmairChaudhry1
New Contributor

I am trying to use the bookmarks widgets for my web application which has recently been released with version 4.8. The trouble is although I have given my collection of bookmark but when I intialise  the widget object it makes the bookmarks collection to null. It seems like the widget only works if the view is based on a webmap with predefined bookmarks. If I have my own collection <bookmark> of bookmark objects and the widget bookmarks is empty.

for (let item of _config.bookmarksOptions) {
let bk = new Bookmark({
extent: item.extent,
name: item.name
})
bcollection.add(bk)
}

//length of bcollection is 4

let bookmarkWidget = new Bookmarks({
view: vw,
bookmarks: bcollection
});

//length of bookmarkWidget.bookmarks is 0

Can anyone shed light on this issue.

Regards,

Omair

0 Kudos
4 Replies
ReneRubalcava
Frequent Contributor

This will probably be improved in the future, but for 4.8, you can add the bookmarks to the map first.

Local bookmarks 

  const map = new WebMap({
    basemap: "streets",
    bookmarks: myBookmarks
  });
  const view = new MapView({
    container: "viewDiv",
    map: map
  });
  
  const bookmarks = new Bookmarks({ view });
0 Kudos
OmairChaudhry1
New Contributor

Thanks for quick reply. If the only way around is to use WebMap object then it definitely needs to be improved and this limitation be addressed. I'll see if I can adapt my code to use WebMap instead of just Map, for now. 

0 Kudos
ReneRubalcava
Frequent Contributor

You could just use Map if you want. I use WebMap mostly because it's just like Map, just supports webmap ids. You don't need to use a webmap id with it.

0 Kudos
OmairChaudhry1
New Contributor

As per API reference Map doesnt support bookmarks. That's what I have been using and that's the issue I believe. 

0 Kudos