In the 2.x API, I was able to set the map selection via the below code.
MapView.Active.Map.SetSelection(new Dictionary<MapMember, List<long>> { { bFl, oidList } });
in 3.0, this code errors out, but the intellisense says that the SetSelection method takes a SelectionSet object as a parameter.
However, I cannot figure out how to instantiate a SelectionSet object. There is no useful information in the API reference for SelectionSet, and the only snippet for the .SetSelection() method is how to clear the selection with .SetSelection(null).
So I am at a loss. How does one programatically select features on the map with the new 3.0 API, given a BasicFeatureLayer object and a list of objectIDs?
Solved! Go to Solution.
If you have the dictionary as in:
var selectionDictionary = new Dictionary<MapMember, List<long>>();
You can then use the static 'FromDictionary' method to create a selection set like this sample (from community samples) that uses a selection set to flash a set of corresponding features:
await QueuedTask.Run(() => { //Flash the collection of features. var selectionSet = SelectionSet.FromDictionary(selectionDictionary); mapView.FlashFeature(selectionSet); });
Also there is a sample in the 3.0-Migration-Guide that you can find if you search for "SelectionSet" or "FromDictionary".
If you have the dictionary as in:
var selectionDictionary = new Dictionary<MapMember, List<long>>();
You can then use the static 'FromDictionary' method to create a selection set like this sample (from community samples) that uses a selection set to flash a set of corresponding features:
await QueuedTask.Run(() => { //Flash the collection of features. var selectionSet = SelectionSet.FromDictionary(selectionDictionary); mapView.FlashFeature(selectionSet); });
Also there is a sample in the 3.0-Migration-Guide that you can find if you search for "SelectionSet" or "FromDictionary".
Thank you so much, @Wolf. I appreciate your reply, and so does my blood pressure & sanity 🙂