You need to fix your service and have every ID match their index.
I was told that top:5 may actually be accessing ID=6, that's why it worked and top:6 is trying to access ID=7, which is already out of bound... as caused by the broken layer (ID=1).
ID=1 may be missing because it was not published but is still contained in your ArcMap Table of Contents. You can either delete layer with ID=1 from ToC or include it and re-publish.
tolerance 2returnGeometry truemapExtent 3219613.08846863,1726402.76275839,3226995.61041765,1732899.38207353layers top:6imageDisplay 1175,825,96geometryType esriGeometryPolygongeometry {"spatialReference":{"wkid":2232},"rings":[[[3219613.08846863,1732899.38207353],[3226995.61041765,1732899.38207353],[3226995.61041765,1726402.76275839],[3219613.08846863,1726402.76275839],[3219613.08846863,1732899.38207353]]]}f json
Server Error - Index was outside the bounds of the array.Code: 500
Server Error - Index was outside the bounds of the array
void QueryTask_Failed(object sender, TaskFailedEventArgs e) { if (e.Error is ServiceException) { StringBuilder sb = new StringBuilder(); foreach(string detail in (e.Error as ServiceException).Details) sb.Append(string.Format("{0}\n", detail)); MessageBox.Show(string.Format("Error: {0}", sb.ToString())); } }
Error {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState) --- End of inner exception stack trace --- at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result) at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)} System.Exception {System.Net.WebException}
The only method I've found is to keep track of which layers are visible at a given "scale" (ESRI deprecates that term nowadays) and provide those IDs with the "all" option each time I make an identify request. It takes a bit of logic to sort through the layers, I'm afraid.Check out the table of contents at the silverlight code gallery for an example of maintaining visibility info. You can use REST calls to grab the min and max scales for each layer, but that's pretty chatty. To keep things simpler, what I ended up doing was create a WCF service to get all the layer info with one SOAP call: if you add a web reference to the map service in your ASP project it automatically builds the methods and data structures for you.
ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters { Geometry = clickPoint, MapExtent = Map.Extent, Width = (int)Map.ActualWidth, Height = (int)Map.ActualHeight, LayerOption = LayerOption.all, }; //these identifyParams.LayerIds.Add do nothing if LayerOption is set to visible //these identifyParams.LayerIds.Add work if LayerOption is set to all but doesn't respect if the layers are turned on/off identifyParams.LayerIds.Add(1); identifyParams.LayerIds.Add(5); identifyParams.LayerIds.Add(14); identifyParams.LayerIds.Add(17); identifyParams.LayerIds.Add(18); // identifyParams.LayerIds = [2, 5]; This errors out not sure how to list a list
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.
#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
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.