monzay

Zoom to graphic

Discussion created by monzay on Dec 13, 2011
Latest reply on Dec 13, 2011 by monzay
I still don't understand how to zoom to the extent of a feature(graphic). The help/samples are not quite basic enough. I can see my graphic but I cannot zoom to it. I also want to use expand.

function showResults(featureSet){
 map.graphics.clear();
        var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID).setColor(new dojo.Color([255, 0, 0, 0.5])); 
        //Loop through features in the featureSet and add them to the map.
        for (var i=0, il=featureSet.features.length; i<il; i++) {
 //Get the current feature from the featureSet.
        //Feature is a graphic
            var graphic = featureSet.features[i];
            graphic.setSymbol(symbol);
     graphic.geometry.getExtent().expand(0.5); //my attempt
   
            //Add graphic to the map graphics layer.
            map.graphics.add(graphic);
          }
  }

Outcomes