Select to view content in your preferred language

Identify problem

4483
35
04-25-2011 11:43 AM
DanielSchatt
Regular Contributor
I'm trying to use the identify functionality that is in the Identify sample. I have set

LayerOption = LayerOption.Visible

just as in the sample.  I assumed this means that all layers are accessible by the identify tool, but only layers that are checked as visible in the web application at any given time will be identified.  That's what I want.

But what's happening is that the identify function is only working on the layers that I set as visible in the original .mxd (and which therefore show initially as visible when I load the web site).  Those layers will always be identified in the web application whether they are visible or not, and other layers will never be identified whether they are visible or not.

Is this what's supposed to happen?  How can I get it to behave as I want? Thanks so much for any help...
0 Kudos
35 Replies
JannalynPontello
Deactivated User
Are you getting an error anywhere? Have you put a breakpoint in your code to make sure the visible layers are being populated? Without an error it's hard to know where things are going wrong.
0 Kudos
BarraLoubna
Deactivated User
Well, before noticing that the identifier brings up all the layers, without taking into consideration those that are not checked, the Identify walk very well. And I get no error, that is why I am lost

May be I misunderstood  the first part of your sentence.
0 Kudos
JannalynPontello
Deactivated User
You have an if statement that exits out of the code if there are no visible layers.

"if (dynamicServiceLayer.VisibleLayers.Length == 0) return;"

I thought maybe your data layers were not loading correctly. Have you checked to make sure they are loading?
0 Kudos
BarraLoubna
Deactivated User
Thank you for your answer.

I got the same thing when I removed the condition :
"if (dynamicServiceLayer.VisibleLayers.Length == 0) return;"

Of course I have verified that the layers appear, you can see the result in the image below.

but I noticed that I receive the same result that is in the picture when I click outside the limits of my layers, I would say to the outside of the administrative boundary of Luxembourg, or layer it no exists.

So maybe I had made a mistake in this line:

IdentifyTask identifyTask = new IdentifyTask (dynamicServiceLayer.Url);
or:
ArcGISDynamicMapServiceLayer dynamicServiceLayer = (ArcGISDynamicMapServiceLayer) MyMap.Layers ["Limites_Administratives"];

I put an image of a part of my code
0 Kudos
BarraLoubna
Deactivated User
and when I use the code in the attached file, it works great, but it makes me appear in the combobox all layers, even that they are not checked in the list of layers.

What do you think?

Thank you for your help.
0 Kudos
JannalynPontello
Deactivated User
Your original identify code referenced a dynamic service layer. In the image you attached showing your xaml, it looks like all your data layers are feature layers, so changing your url to the full address fixes that. But it looks like you removed the code that adds the layers to the identify parameters. This is what you had previously, so you'll need to change it to reference the new url.

     if (dynamicServiceLayer.VisibleLayers != null)
     foreach (int x in dynamicServiceLayer.VisibleLayers)
     identifyParams.LayerIds.Add(x);
     if (dynamicServiceLayer.VisibleLayers.Length == 0) return;
0 Kudos
BarraLoubna
Deactivated User
Yes, I know that my layers are called as features layers, because I am appealing to the layers attribute table ...
What is the code that I had deleted and it called identify parameter .
And how to Reference the new URL.
Please help me, I'm not strong in programming.

Please help me.
0 Kudos
JannalynPontello
Deactivated User
In your original code, you used this to define the url, which is the way I did it.

"ArcGISDynamicMapServiceLayer dynamicServiceLayer = (ArcGISDynamicMapServiceLayer)MyMap.Layers["Limites_Administratives"];"

But you don't have an ArcGISDynamicMapServiceLayer defined in your xaml, because you're using feature layers. That's probably why your identify task didn't return any results.

I would suggest reverting to your original identify code, but use "FeatureLayer" instead of "ArcGISDynamicMapServiceLayer" so that you're referencing the same rest services that your map is using.

I'm not a great programmer either, so hopefully that'll work for you. Let me know.
0 Kudos
BarraLoubna
Deactivated User
I don't understand how the identifier will manage the visibility of layers, if I give the url of the service, while in the service all layers are checked. 

That is why I used the code that is in the top position in this post
0 Kudos
BarraLoubna
Deactivated User
In your original code, you used this to define the url, which is the way I did it.

"ArcGISDynamicMapServiceLayer dynamicServiceLayer = (ArcGISDynamicMapServiceLayer)MyMap.Layers["Limites_Administratives"];"

But you don't have an ArcGISDynamicMapServiceLayer defined in your xaml, because you're using feature layers. That's probably why your identify task didn't return any results.

I would suggest reverting to your original identify code, but use "FeatureLayer" instead of "ArcGISDynamicMapServiceLayer" so that you're referencing the same rest services that your map is using.

I'm not a great programmer either, so hopefully that'll work for you. Let me know.


Thank you very much for your reply, I'll see and I'll come back to inform you.
0 Kudos