IdentifyTask with webmap from AGOL

2816
3
02-14-2013 03:33 AM
AndreiGosman
New Contributor II
Hi everybody,

Doen anyone know how can I use Identify Task with a webmap from AGOL?

IdentifyTask expects a URL to a layer, but using AGOL I only have a webmap ID.

Is there a way?

Thank you
0 Kudos
3 Replies
KellyHutchins
Esri Frequent Contributor
When working with web maps Popups are a good alternative to the identify task. Any popups defined in your web map will display in your web application. If you click on an area of the map with multiple features that have popups defined the popup window will display with navigation tools in the toolbar that let you move through the selected set of features. See the attached screen shot for an example of this behavior.

That said you can use the identify task if you'd like. When you use the createMap function to create a map based on a web map you get access to lots of info in the response object including the map and the layers in the map. In the example below the layers are accessed using response.itemInfo.itemData.operationalLayers.


      esri.arcgis.utils.createMap(webmapid, "mapDiv").then(function(response){
        var layers = response.itemInfo.itemData.operationalLayers;


You can find more information about working with web maps here:
http://help.arcgis.com/en/webapi/javascript/arcgis/jshelp/#intro_webmap
0 Kudos
AndreiGosman
New Contributor II
Hi Kelly,

Thx for your answer, it worked just fine.

I suppose I can use the mechanism (your code snippet) for Query Task?

Thx

Andrei
0 Kudos
KellyHutchins
Esri Frequent Contributor
Hi Andrei,

Yes the same approach will work for a query task - you'll just need to append the index for the layer you want to query.

Kelly
0 Kudos