Generic Identify

781
6
Jump to solution
05-02-2012 06:57 AM
ZahidChaudhry
Occasional Contributor III
Is there a generic identify tool, which finds out which layer was clicked and then return all the attributes...by getting layers and layerIDs just by clicking on the map....
I am going to work on this but i thought should check if anybody already did something similar...
0 Kudos
1 Solution

Accepted Solutions
JeffPace
MVP Alum
Thanks Jeff...Yes i totally agree with you. I wish map click could return something more than mappoint like clicked graphic/layer etc...or map object has event like getAllvisible layers instead of getting all layers..
Thanks again


I agree, unfortunately without querying the map (i.e. looping through the layers) there is no way to know which layer you clicked.

A map.visibleLayerIds would be a very useful property, however.

If you dont mind marking my response as an answer, i would appreciate it 🙂

View solution in original post

0 Kudos
6 Replies
JeffPace
MVP Alum
Is there a generic identify tool, which finds out which layer was clicked and then return all the attributes...by getting layers and layerIDs just by clicking on the map....
I am going to work on this but i thought should check if anybody already did something similar...


There is no identify dijit.  There is an identify task, however, that you can pass an onclick and will let you choose ALL, TOP, or VISIBILE to identify.
0 Kudos
ZahidChaudhry
Occasional Contributor III
There is no identify dijit.  There is an identify task, however, that you can pass an onclick and will let you choose ALL, TOP, or VISIBILE to identify.

Yes but you have to specify the URL and then choose layers...is it a way that you click on map, get all the visible layers and then use all those layers to do the identify?

This way i can write a function where i can pass all the visible layers at map click and then iterate through each layer and get results...

thanks
0 Kudos
JeffPace
MVP Alum
Yes but you have to specify the URL and then choose layers...is it a way that you click on map, get all the visible layers and then use all those layers to do the identify?

This way i can write a function where i can pass all the visible layers at map click and then iterate through each layer and get results...

thanks


Unfortunately you have to do it programmatically.  There are advantages and disadvantages to this. 

Disadvantage - you have to write it
Advantage - you can identify non -visible layers.

Basically you have to take an evt/mappoint and loop through all the map layers and do an identify on each. 

loosely:
var ids = map.layerIds;
dojo.forEach(ids, function(id) {
      var layer = this.map.getLayer(id);
      if (layer.visible==true){
            //do identify on layer.url
      }
}


0 Kudos
ZahidChaudhry
Occasional Contributor III
Thanks Jeff...Yes i totally agree with you. I wish map click could return something more than mappoint like clicked graphic/layer etc...or map object has event like getAllvisible layers instead of getting all layers..
Thanks again
0 Kudos
JeffPace
MVP Alum
Thanks Jeff...Yes i totally agree with you. I wish map click could return something more than mappoint like clicked graphic/layer etc...or map object has event like getAllvisible layers instead of getting all layers..
Thanks again


I agree, unfortunately without querying the map (i.e. looping through the layers) there is no way to know which layer you clicked.

A map.visibleLayerIds would be a very useful property, however.

If you dont mind marking my response as an answer, i would appreciate it 🙂
0 Kudos
ZahidChaudhry
Occasional Contributor III
I agree, unfortunately without querying the map (i.e. looping through the layers) there is no way to know which layer you clicked.

A map.visibleLayerIds would be a very useful property, however.

If you dont mind marking my response as an answer, i would appreciate it 🙂


so after three days of brain storming, I am able to write a generic js that can detect all the visible layers in the map (on Click), do identify, remove on click event, and then display all results into a popup window...very similar to what you see on arcgis online identify.

But My special message to ESRI, please provide us a pure javascript API and let us decided what library i wana use....because documentation on dojo is so crappy that it doesn't make any sense to me...
0 Kudos