I have a map application that harvests it's map layers from a JSON string. I've managed to use the following code to show the map layers when a user clicks on a layer name in a table of contents but any success to use IdentifyTask to return individual features when someone clicks on a map layer is alluding me?! This is an extract of the code that returns the map layers:

for (index in jsonString.Recreation) {
         if (jsonString.Recreation[index].id == myID) {
             var layerURL = jsonString.Recreation[index].url;
             var layerids = jsonString.Recreation[index].layer;
             var fieldids = jsonString.Recreation[index].field;
             //alert('LayerURL or record ' + layerURL + layerids);
             addLayertoMap(layerURL, layerids, fieldids)
for (index in jsonString.Waste) {
if (jsonString.Waste[index].id == myID) {
             var layerURL = jsonString.Waste[index].url;
             var layerids = jsonString.Waste[index].layer;
             var fieldids = jsonString.Waste[index].field;
             addLayertoMap(layerURL, layerids, fieldids)


 function addLayertoMap(layerURL, layerID) {
     var dynamicLayer = map.getLayer("DynamicLayer");
     if (dynamicLayer) {

     var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(layerURL, { "id": "DynamicLayer" });


I've added the fieldids variable in the for loop so that I can use IdentifyTask to allow users to click on map layers to return their attributes, this is the code so far:

   function initIdentify(evt) {
     //create identify tasks and setup parameters
     identifyTask = new esri.tasks.IdentifyTask(fieldids, { "id": "DynamicLayer" });

     identifyParams = new IdentifyParameters();
     identifyParams.tolerance = 12;
     identifyParams.returnGeometry = true;
     identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;
     identifyParams.width = map.width;
     identifyParams.height = map.height;
     map.on("click", executeIdentifyTask);

Is it possible to add the results of the IdentifyTask to a div?

  • Which version of the API are you using? – Mintx Aug 14 '15 at 17:36
  • Hi, I'm using 3.9. – beppe d'angelo Aug 17 '15 at 15:52
  • 1
    If you paste the code for your executeIdentifyTask function, then that might help troubleshoot the problem. – Mintx Aug 18 '15 at 22:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.