1

I am identifying features from an ArcGISDynamicMapServiceLayer

All the sublayers can be toggle on/off and when identifying, only the visible layers are queried/returned. Below are the initIdentify and executeIdentifyTask functions.

   dojo.connect(map, "onLoad", function(map) {initIdentify(map);});


   function initIdentify(map) {             
            //create identify tasks and setup parameters
            identifyTask = new esri.tasks.IdentifyTask("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");                
            identifyParams = new esri.tasks.IdentifyParameters();
            identifyParams.tolerance = 3;
            identifyParams.returnGeometry = true;
            identifyParams.layerIds = wmsLayer.visibleLayers;               
            identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
            identifyParams.width = map.width;
            identifyParams.height = map.height;             
            dojo.connect(map, "onClick", executeIdentifyTask);
        }

   function executeIdentifyTask(evt) {
            if (visibleLayers.length === 0){                    
                return;
            } else {
                identifyParams.geometry = evt.mapPoint;
                identifyParams.mapExtent = map.extent;
                identifyParams.layerIds = wmsLayer.visibleLayers;               
                identifyTask.execute(identifyParams, function(idResults) { fillInfoWindow(idResults, evt); });                   
            }
  }

When the identify function is run, is there a way to highlight/select those features that are being identified?

1 Answer 1

1

Create a FeatureLayer on top of the dynamic layer, with the same service source (except, obviously, using the correct layer in the map service rather than just the map service, e.g. http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/0).

As some part of your event handling (you could make it a new handler, make it part of executeIdentifyTask, part of fillInfoWindow, part of the anonymous callback on your Identify Task, or an additional callback on Identify Task), execute SelectFeatures against your featureLayer.

For SelectFeatures, use your evt.mapPoint as the geometry for your Query geometry and esri.layers.FeatureLayer.SELECTION_NEW for your selectionMethod. Everything else should be able to use the defaults.

Remember to use FeatureLayer.setSelectionSymbol(symbol) to define the symbol for the selection.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.