I currently have a map service that allows the user to click the map, and any visible feature will be selected, and added to a ComboBox using an Identity Task based on the mouse click point.I now need to modify the code so that any visible feature which touches any of the selected features, will also become selected and added to the combobox. My initial thought was to mimic the buffer query http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#BufferQuery and have any visible feature which touches the graphics layer become selected itself. How would I go about adding the additional features selected from the Query Task into IdentifyResults? I've pasted the code for my identify task, as well as the code that populates the combobox.
public void ShowFeatures(List<IdentifyResult> results)
{
_dataItems = new List<DataItem>();
if (results != null && results.Count > 0)
{
IdentifyComboBox.Items.Clear();
foreach (IdentifyResult result in results)
{
Graphic feature = result.Feature;
string title = result.Value.ToString() + " (" + result.LayerName + ")";
_dataItems.Add(new DataItem()
{
Title = title,
Data = feature.Attributes
});
IdentifyComboBox.Items.Add(title);
}
// Workaround for bug with ComboBox
IdentifyComboBox.UpdateLayout();
IdentifyComboBox.SelectedIndex = 0;
}
IdentifyDetailsDataGrid.IsEnabled = false;
}
private void IdentifyTask_ExecuteCompleted(object sender, IdentifyEventArgs args)
{
IdentifyDetailsDataGrid.ItemsSource = null;
if (args.IdentifyResults != null && args.IdentifyResults.Count > 0)
{
IdentifyResultsPanel.Visibility = Visibility.Visible;
ShowFeatures(args.IdentifyResults);
}
else
{
IdentifyComboBox.Items.Clear();
IdentifyComboBox.UpdateLayout();
//IdentifyResultsPanel.Visibility = Visibility.Collapsed;
}
//test to colour clicked layers
GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
if (args.IdentifyResults.Count > 0)
{
foreach (IdentifyResult result in args.IdentifyResults)
{
Graphic graphic = result.Feature;
switch (graphic.Attributes["Shape"].ToString())
{
case "Polygon":
graphic.Symbol = DefaultFillSymbol;
break;
case "Polyline":
graphic.Symbol = DefaultLineSymbol;
break;
case "Point":
graphic.Symbol = DefaultMarkerSymbol;
break;
}
graphicsLayer.Graphics.Add(result.Feature);
}
}
else
{
// MessageBox.Show("Found " + args.IdentifyResults.Count + " Features");
}
}
Thanks for any help, I think my logic is correct but I'm not sure the best way to get there. Can I simply run something like ShowFeatures(args.QueryResults); for the additional selected features?