function onRowClickHandler(evt){ var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID; var selectedTaxLot; dojo.forEach(map.graphics.graphics,function(graphic){ if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId){ selectedTaxLot = graphic; return; } }); var x = esri.geometry.webMercatorToGeographic(selectedTaxLot.graphic); var areas = esri.geometry.geodesicAreas(x, esri.Units.ACRES); console.log(areas); var taxLotExtent = selectedTaxLot.geometry.getExtent(); map.setExtent(taxLotExtent); }
Solved! Go to Solution.
map.setExtent(taxLotExtent, true)with the boolean parameter as you suggested in an earlier post to make sure it fit within the window.
Thanks for both of those answers.
Using expand with setExtent and the true option helps. But I have features that range in size from as big as the Gulf of Mexico to some dinky island in the middle of it. For the small area it would be helpful to see it within the context of nearby land or some other reference information from the Ocean basemap. That is why I was asking if there was a way to evaluate the size or shape of the area and then set a zoom level.
var taxLotExtent = selectedTaxLot.geometry.getExtent(); var height = taxLotExtent.ymax-taxLotExtent.ymin; var width = taxLotExtent.xmax - taxLotExtent.xmin; if (width < someSmallWidth or height < someSmallHeight){ taxLotExtent = taxLotExtent.expand(5); }else{ taxLotExtent = taxLotExtent.expand(1.25); }
map.setExtent(taxLotExtent, true)with the boolean parameter as you suggested in an earlier post to make sure it fit within the window.