I am trying to store bookmarks on the client local-storage but I can't seem to intercept the following events on the bookmark widget or on the BookmarkViewModel class [on Create, Update, Delete]. I would like to use the bookmark widget for its UI. Any idea?
Bookmarks | ArcGIS API for JavaScript 4.14
BookmarksViewModel | ArcGIS API for JavaScript 4.14
Thanks
You can listen for the bookmarks collections change event. You'll want to wait until the webmap is ready so the bookmarks are populated. Here's an example: https://codepen.io/kellyhutchins/pen/ExjPGQe
Yep looks like you'd want to watch the name property.
bookmarkWidget<SPAN class="punctuation token">.</SPAN>bookmarks<SPAN class="punctuation token">.</SPAN><SPAN class="token function">forEach</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN>bookmark<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> bookmark<SPAN class="punctuation token">.</SPAN><SPAN class="token function">watch</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="punctuation token">(</SPAN>name<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">log</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Name Changed"</SPAN><SPAN class="punctuation token">,</SPAN> name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thank you Kelly,
The "Add", and "Remove" event works great! I was able to capture those two events. then what about when the bookmark's name gets updated? I was looking for an event like "updated". I am wondering if I can watch for the property name change using watchUtils | ArcGIS API for JavaScript 4.14 ?
Thank you
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.