dymaptic / GeoBlazor

Core Components for the Dymaptic GeoBlazor Library
MIT License
109 stars 19 forks source link

Add OnBookmarkEdit event to BookmarksWidget #361

Open TimPurdum opened 3 months ago

TimPurdum commented 3 months ago

Requested on Discord. Expose the bookmark-edit event to GeoBlazor through the BookmarksWidget.

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Bookmarks.html#event-bookmark-edit

pseudo-JavaScript workaround until this is implemented:

export function captureBookmarkEdit(core, widgetId, classRef) {
    let bookmarks = core.arcGisObjectRefs[widgetId];
    bookmarks.on('bookmark-edit', async () => {
        await classRef.invokeMethodAsync('OnBookmarkEdit');
    });
}

calling code:

private async Task OnViewRendered() 
{
    await yourJsModule.InvokeVoidAsync("captureBookmarkEdit", View.JsModule, bookmarkWidget.Id, DotNetObjectReference.Create(this));
}

[JsInvokable]
private async Task OnBookmarkEdit()
{
   // do your work here
}