angelg:
As shapGIS said you have to set the LayersIds property, but don't set LayerOption at the same time. Use LayerOption property (All, Top, Visible) if you start up your service with any layer visible.
Try to use for example LayerIds = [0,1,2,etc] . It works for me using 110 layers off at startup.
I hope it helps.
Ernesto,If I change the LayerOption = LayerOption.all the identify tool will identify all my layers no matter what is checked in my sublayer list. If I change LayerOption = LayerOption.visible the identify tool doesn't respect the layerlist.....it only identifies the layers that were visible at startup. Where do I hard code the layers (like you stated) LayerIds = [0,1,2,etc] I can't find this code and I'm unsure where to add it? Or better yet how do I make the identify pick up the new visible layers from the sublayer list?ThanksD
#region Identify
// Jay's Identify
private void QueryPoint_MouseClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
e.Handled = true; // to get rid of the default "Silverlight" Context Menu.
ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = this.Map.ScreenToMap(e.GetPosition(Map));
ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters()
{
Geometry = clickPoint,
MapExtent = Map.Extent,
Width = (int)Map.ActualWidth,
Height = (int)Map.ActualHeight,
LayerOption = LayerOption.all
};
IdentifyTask identifyTask = new IdentifyTask("http://hqtr-gis10/ArcGIS/rest/services/DRECP_20101008/MapServer");
identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
identifyTask.Failed += IdentifyTask_Failed;
identifyTask.ExecuteAsync(identifyParams);
GraphicsLayer graphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer;
graphicsLayer.ClearGraphics();
ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = clickPoint,
Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
};
graphicsLayer.Graphics.Add(graphic);
}
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);
}
IdentifyComboBox.SelectedIndex = 0;
}
}
void cb_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = IdentifyComboBox.SelectedIndex;
if (index > -1)
IdentifyDetailsDataGrid.ItemsSource = _dataItems[index].Data;
}
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);
ShowIDtab.Begin();
}
else
{
IdentifyComboBox.Items.Clear();
IdentifyComboBox.UpdateLayout();
IdentifyResultsPanel.Visibility = Visibility.Collapsed;
}
}
public class DataItem
{
public string Title { get; set; }
public IDictionary<string, object> Data { get; set; }
}
void IdentifyTask_Failed(object sender, TaskFailedEventArgs e)
{
MessageBox.Show("Identify failed. Error: " + e.Error);
}
//end Jay's identify
#endregion