I think I know the answer to this but here goes. What I need (beyond the selected features) is the geometry of the selection area in map coordinates. What I'd like is to simply use what is already provided since that works great:
I see where I can use:
MapSelectionChangedEvent.Subscribe(OnSelectionChanged);
to be notified when the selection is made and I get the features selected:
private void OnSelectionChanged(MapSelectionChangedEventArgs args)
{
if (args.Map != _activeMap)
return;
UpdateForActiveMap(false, args.Selection.ToDictionary());
}
With this, I'm not seeing how to get the geometry of the selection area. Is there a way to get the selection area without writing a whole new selection tool ala: FeatureSelectionTool?
Thanks!
The input geometry is not passed through to the event handler. You can easily write your own tool by creating a MapTool, then changing the SketchType (Rectangle, Line, Polygon etc.), and adding these lines to the OnSketchCompleteAsync method:
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
QueuedTask.Run(() =>
{
var selectionSet = MapView.Active.SelectFeatures(geometry);
OnMySelectionEvent(geometry, selectionSet);
});
return base.OnSketchCompleteAsync(geometry);
}
Now you call your own event handler passing in the selection and the geometry.
Yes. That's what I expected. It is unfortunate that I need to replicate what is already there and working.