dymaptic / GeoBlazor

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

Add LayerList Widget #40

Closed TimPurdum closed 2 years ago

TimPurdum commented 2 years ago

ArcGIS API for JavaSript - LayerList

  1. Add logic to the switch statement in the arcGisJsInterop.ts function addWidget() to handle the LayerList widget type. This should set the following values (if set in C#):
    • iconClass (string)
    • label (string)
    • view - this should be set to the view found at the top of addWidget()
  2. Add an event handler for the following events that calls back to the dotnet object reference for the listItemCreatedFunction event. Use the Search widget as an example.
  3. Create a new backlog gissue to add LayerListViewModel abilities later.
  4. Create a file ...Core\Components\Widgets\LayerListWidget.cs that inherits from Widget.cs, and has public string? IconClass and public string? Label with the [Parameter] and [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] attributes.
  5. Add the code for the ListItemCreated event handler to LayerList.Widget.cs, again using SearchWidget.cs as a template.
  6. Create a new samples page based on this demo
TimPurdum commented 2 years ago

Based on discussions with @seahro and @morehavoc , here are some steps for implementation.

  1. Create a method buildDotNetListItem(item: ListItem) that converts an arcgis ListItem to something that the C# json parser can handle.
  2. When adding the widget, set layerListWidget.listItemCreatedFunction to a new anonymous function, e.g. layerListWidget.listItemCreatedFunction = (evt) => { };
  3. Implement ListItem in C#.
  4. Change OnLayerListSelectResult and OnLayerListSelectResultHandler to OnListItemSelected and OnListItemSelectedHandler in LayerListWidget.cs.
  5. Update the call to C# in listItemCreatedFunction to something like widget.DotNetObjectReference.InvokeAsync<DotNetListItem>('OnListItemSelected, dotNetListItem)to return theDotNetListItem` back. Verify that the data is getting set in C#.
  6. In LayerListWidget.cs, change the event handler to public Func<ListItem, Task<ListItem>>? OnListItemSelectedHandler {get; set;}.
  7. In the [JSInvokable] method LayerListWidget.OnListItemSelected(ListItem item), do return OnListItemSelectedHandler?.Invoke(item).
  8. Create a new samples page, LayerLists.razor that has multiple layers, and implements a method for OnListItemSelected.

I'm sure that we will hit more snags along the way, but this should hopefully add a bit more guidance.