function onRowClickHandler(evt) { var clickedTaxLotId = grid.getItem(evt.rowIndex).OBJECTID; var selectedTaxLot; dojo.forEach(map.graphics.graphics, function(graphic) { if((graphic.attributes) && graphic.attributes.OBJECTID === clickedTaxLotId) { selectedTaxLot = graphic; return; } }); var taxLotExtent = selectedTaxLot.geometry.getExtent(); map.setExtent(taxLotExtent); }
Solved! Go to Solution.
//Zoom to the parcel when the user clicks a row function onRowClickHandler(evt){ var clickedId = grid.getItem(evt.rowIndex).OBJECTID; var g; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.OBJECTID === clickedId){ g = graphic; return; } }); if (g.geometry.type == "point"){ var pExtent = new esri.geometry.Extent({"xmin":g.geometry.x - 500,"ymin":g.geometry.y - 500,"xmax":g.geometry.x + 500,"ymax":g.geometry.y + 500,"spatialReference":{"wkid":g.geometry.spatialReference.wkid}}); map.setExtent(pExtent); } else{ var gExtent = g.geometry.getExtent(); map.setExtent(gExtent); } }
//Zoom to the parcel when the user clicks a row function onRowClickHandler(evt){ var clickedId = grid.getItem(evt.rowIndex).OBJECTID; var g; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.OBJECTID === clickedId){ g = graphic; return; } }); if (g.geometry.type == "point"){ var pExtent = new esri.geometry.Extent({"xmin":g.geometry.x - 500,"ymin":g.geometry.y - 500,"xmax":g.geometry.x + 500,"ymax":g.geometry.y + 500,"spatialReference":{"wkid":g.geometry.spatialReference.wkid}}); map.setExtent(pExtent); } else{ var gExtent = g.geometry.getExtent(); map.setExtent(gExtent); } }
Rachel,
There are a lot of posts on this subject and I think I handle it somewhat differently, which probably is not correct or good coding cause I'm a total hack but here's how I handle it://Zoom to the parcel when the user clicks a row function onRowClickHandler(evt){ var clickedId = grid.getItem(evt.rowIndex).OBJECTID; var g; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.OBJECTID === clickedId){ g = graphic; return; } }); if (g.geometry.type == "point"){ var pExtent = new esri.geometry.Extent({"xmin":g.geometry.x - 500,"ymin":g.geometry.y - 500,"xmax":g.geometry.x + 500,"ymax":g.geometry.y + 500,"spatialReference":{"wkid":g.geometry.spatialReference.wkid}}); map.setExtent(pExtent); } else{ var gExtent = g.geometry.getExtent(); map.setExtent(gExtent); } }
That should work!
If my post helped or answered your question please send a point my way!
Jay
You should be able to just use the map methods centerAndZoom or centerAt.
All you should need is map.centerAt(selectedTaxLot.geometry) or map.centerAt(selectedTaxLot.geometry, 24)
Hope that helps!
Jay