pigili_sreenivasarao

How zoom into selected feature (multiple features will get selected)

Discussion created by pigili_sreenivasarao on Dec 21, 2012
Latest reply on Dec 21, 2012 by rahul_m
Hi,
   I have exported my task results into a grid view. Now if I select any row from the gridview, i am able to zoom into that particular feature by using the ESRI provided link under 'Show find task results in a DataGrid '.
   Now I am planning to extend the provided code - in such a way that - if I selects multiple features from the grid view, then also we have to zoom into those features. For this I have modified the existing code in below ways.
1. Taken all the selected features and added into one featureset. But in the featureset we dont have extent property to set to mapextent.
2. Taken all the graphics into a graphics layer. Here also we dont have extent property to set to mapextent.

Please find the used code below.

      //Zoom to the parcel when the user clicks a row
      function onRowClickHandler(evt)
   {
        var items = grid.selection.getSelected();
        for(var i=0;i<items.length;i++)
        {
   var clickedTaxLotId = items[i].PARCELID;
   var selectedTaxLot;
  
   var countyLayer = new esri.layers.GraphicsLayer();
      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,194,204,0.5]));
           
   var features= [];
   var featureSet = new esri.tasks.FeatureSet();
   dojo.forEach(map.graphics.graphics,function(graphic)
   {
    if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId)
    {
     features.push(graphic);
     featureSet.features = features;

     //countyLayer.add(graphic.geometry, symbol);
     //map.setExtent(countyLayer);
     //selectedTaxLot = graphic;
     return;
    }
   });
   //var taxLotExtent = selectedTaxLot.geometry.getExtent();
            //map.setExtent(taxLotExtent);
   map.setExtent(featureSet.Extent);
        }
      }



Can anyone help in this regards. Thanks in advance.

Outcomes