Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 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.

share|improve this answer
    
thanks blord-castillo.. is that what you did in this example to get the identified features to appear selected? jsfiddle.net/blordcastillo/Ddt8V –  snowgage Mar 15 '13 at 19:43
    
That's actually a different concept using the popup dijit. help.arcgis.com/en/webapi/javascript/arcgis/jsapi/popup.html I completely forgot about that idea, and it can actually do exactly what you want! –  blord-castillo Mar 15 '13 at 19:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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