elove

Select Multiple Features Using Identify Task?

Discussion created by elove on Jan 10, 2012
Latest reply on Jan 27, 2012 by elove
Hello,

I have a identify function that is working when I select one feature on the map at a time. The results are then sent to a datagrid. I would like the option to be able to select multiple features at a time by drawing a rectangle on the map. Ideally, the user could chose which layer to view data for through a window prompt. Is this possible or does Identify only work on one feature at a time?

Thanks so much for any advice!!


function doIdentify(evt) {
    
        map.infoWindow.hide();
        identifyParams.layerIds = [0,2];
     
       
  
      var measureMode =   dojo.query(".esriButton .dijitButtonNode").some(function(node, index, arr){
          if(node.childNodes[0].checked){
            //at least one of the measure tools is active so disable identify
            return true;
            
          }
       });
       if(! measureMode){
        map.graphics.clear();
        identifyParams.geometry = evt.mapPoint;
        identifyParams.mapExtent = map.extent;
        identifyTask.execute(identifyParams,showResults); 
      }  
       }
 
  function showResults(results) {

     map.graphics.clear();
        var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,94,204,0.8]));
        var idLayer;
        var highlightSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([25,50,225,0.3])); 
 

        //create array of attributes
          var items = dojo.map(results,function(result){
          var graphic = result.feature;
          graphic.setSymbol(symbol);
          map.graphics.add(graphic);
      //Highlight selected feature
     graphic.setSymbol(highlightSymbol);
     return result.feature.attributes;
        }); 
    
      //Create data object to be used in store
 if (results[0].layerName == 'Control Points') {
 showPointNameGrid();
 searchType = "selControl";
 
          var data = { 
 identifier: 'POINT_NAME',  //This field needs to have unique values 
            label: 'POINT_NAME', //Name field for display. Not pertinent to a grid but may be used elsewhere. 
 items: items 
   };  
 
     //Create data store and bind to grid. 
   store = new dojo.data.ItemFileReadStore({ data:data }); 
   var grid = dijit.byId('grid4'); 
  grid.setStore(store);  
  
} else if (results[0].layerName == 'surveys') {
       showSurveysNameGrid();
 searchType = "selSurvey";
 var data = { 
 identifier: 'DOCUMENT_N',  //This field needs to have unique values 
  label: 'DOCUMENT_N', //Name field for display. Not pertinent to a grid but may be used elsewhere. 
  items: items 
}; 
   
 store = new dojo.data.ItemFileReadStore({ data:data }); 
 var grid = dijit.byId('grid5'); 
 grid.setStore(store);  
   
 } else if (results[0].layerName == 'Cities') {
 showCityGrid();
 var data = { 
  identifier: 'CITY',  //This field needs to have unique values 
 label: 'CITY', //Name field for display. Not pertinent to a grid but may be used elsewhere. 
 items: items 
 }; 
   
 store = new dojo.data.ItemFileReadStore({ data:data }); 
 var grid = dijit.byId('grid2'); 
 grid.setStore(store); 
  }
  }

Outcomes