elove

Zoom To Point From Datagrid

Discussion created by elove on Sep 21, 2011
Latest reply on Oct 6, 2011 by mstarr
Hello,

I am super new to JavaScript and am attempting to zoom to a point from a data grid using the code below. However, it is not zooming, and in Firebug I get an error saying:
selectedTaxLot.geometry.getExtent() is null on this line of code:
var screenpoint = map.toScreen(selectedTaxLot.geometry.getExtent().getCenter());

Any help would be greatly appreciated!!

//Zoom to the parcel when the user clicks a row
      function onRowClickHandler(evt){
        var clickedTaxLotId = grid.getItem(evt.rowIndex).City;
        var selectedTaxLot;

        dojo.forEach(map.graphics.graphics,function(graphic){
          if((graphic.attributes) && graphic.attributes.City === clickedTaxLotId){
            selectedTaxLot = graphic;
            //added this part to build infotemplate
             map.infoWindow.setTitle(graphic.getTitle());
             map.infoWindow.setContent(graphic.getContent());
              //
            return;
          }
        });
        var taxLotExtent = selectedTaxLot.geometry.getExtent();
        var screenpoint = map.toScreen(selectedTaxLot.geometry.getExtent().getCenter());
        var mappoint = map.toMap(screenpoint);

       // map.setExtent(taxLotExtent);

         map.centerAt(mappoint);
         map.infoWindow.show(taxLotExtent.getCenter(), map.getInfoWindowAnchor(screenpoint));
        
      }
function oc(a)
    {
      var o = {};
      for(var i=0;i<a.length;i++)
      {
        o[a[i]]='';
      }
      return o;
   }

Outcomes