Select to view content in your preferred language

Identify Task issues

6348
25
04-13-2010 08:40 AM
AngelGonzalez
Frequent Contributor
I am using the ESRI sample for Identify and got a problem. I have a sublayer list with about 13 layers. Only the first 4 are set to be visible when the silverlight app is first run. The identify Task works fine with these first 4 layers. When I click on the checkbox to make another layer visible and use the Identify tool the fifth layer does not appear on the identify tool. Yet when I go back and update the mxd to make the fifth layer visible and reboot my ArcGIS server (the refreshing of a service to pickup and any changes made to the mxd is not being pickup by Silverlight app, only a reboot will do this , bug??) the identify tool picks up the the fifth layer. 

Does the Identify task works with sublayer list? Do I need to refresh something?
I am using SL3 with ESRI 1.2 SL API

Thanks

Angel
0 Kudos
25 Replies
JenniferNery
Esri Regular Contributor
For your first question:
identifyParams.LayerOption = LayerOption.visible;
For your second question:
identifyParams.LayerIds.AddRange(new int[] {1,5,17,18});
0 Kudos
MarkCederholm
Frequent Contributor
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.
0 Kudos
SanjayRajput
Deactivated User
Hello Mark Cederholm/Others
   I am looking for the code snippet to find the current visible layers of a given dynamicmapservice.
During application startup, dynamicmapservice loads all visible layers on the map(defined in the mxd). But after a while users can TURNON/TURNOFF layers. And when I do the QUERYTASK, I should be able to QUERY only current visible layers.
Thanks
Sanjay

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.
0 Kudos
MarkCederholm
Frequent Contributor
Again, I highly recommend the Silverlight Table of Contents code example in the code gallery.  Here's a link to it:

http://www.arcgis.com/home/item.html?id=acad4f3fb7d04854ab8dbe3fc5f79fc5
0 Kudos
MatthewPilgrim
Regular Contributor
Hi,

I have a similar issue to the first poster (my last layer fails) however my layer is on by default and I get this exception from ESRI.ArcGIS.Client.Tasks.TaskFailedEventArgs:

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}


My service has layer ids 0,2,3,4,5,6 (note no number one - and none of them are group layers).  All work except 6.  I have tried calling the Identify task with and without layer options but I still get the exception. 

If I pass in Id "5" the results come back for a layer with the correct name - excellent.
If I pass in Id "1" I don't get an exception, but I also get no results.
If I pass in Id "7" I get the same exception as before.

Any Ideas?

Thanks, Matt
0 Kudos
JenniferNery
Esri Regular Contributor
Subscribe to Failed event and check for exception. Also, you might want to run Fiddler with your application to see more information on which web request failed.

 
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()));
 }
}


If the layer ID is up to 6, ID=7 is expected to fail, right?

Try to see if putting the same parameters from the web browser will result to the same error.
0 Kudos
MatthewPilgrim
Regular Contributor
Jennifer thanks for your response.

Yes I expect 7 to fail.

The exception is of type "System.Net.WebException" so I don't think your code snippet helps.

I'm looking into fiddler and calling the service, not something I've done before.

Matt
0 Kudos
JenniferNery
Esri Regular Contributor
You can place a breakpoint in the Failed event handler, if it does go there.

Post #14 in this thread might guide you in finding what you need to look for in Fiddler: http://forums.arcgis.com/threads/14730-Area-And-Perimeter
0 Kudos
MatthewPilgrim
Regular Contributor
Hi,

the exception I posted orginally was fromn the failed event handler and is as much information as I can see at that point.

From fiddler I can see the server response is:
Server Error - Index was outside the bounds of the array


This is the service:



This is me calling it (note the watch value is 6):



I'm trying to callit direct at the moment.

Matt
0 Kudos
MatthewPilgrim
Regular Contributor
from fiddler:

tolerance 2
returnGeometry true
mapExtent 3219613.08846863,1726402.76275839,3226995.61041765,1732899.38207353
layers top:6
imageDisplay 1175,825,96
geometryType esriGeometryPolygon
geometry {"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


One thing I notice is that it says "top:6", I didn't specify Top.

I have now tested the webservice direct with All:6 and Top:6 and in both cases get:

Server Error - Index was outside the bounds of the array.

Code: 500


Is it really using Ids and not Index or is it doing a bit of both????

Matt
0 Kudos