Nate, So here it is tested and working using some data on my side.import com.esri.ags.FeatureSet;
import com.esri.ags.utils.GraphicUtil;
private function zoomToButton_clickHandler(event:MouseEvent):void
{
var graphic:Graphic = hostComponent.graphic;
var map:Map = hostComponent.map;
var geometry:Geometry = graphic.geometry;
var extent:Extent = geometry.extent; // returns null for MapPoint or Multipoint's with only one point
if (graphic.attributes.hasOwnProperty("Road_Id") &&
graphic.attributes.hasOwnProperty("Monument_Z")){
var featLay:FeatureLayer = new FeatureLayer("http://myserver/ArcGIS/rest/services/myservice/MapServer/5");
featLay.useAMF = true;
var query:Query = new Query();
query.outSpatialReference = map.spatialReference;
query.where = "ID = " + graphic.attributes.Road_Id;
query.returnGeometry = true;
featLay.queryFeatures(query, new AsyncResponder(qResult, qFault));
function qResult(featureSet:FeatureSet, token:XMLList = null):void
{
try{
extent = GraphicUtil.getGraphicsExtent(featureSet.features);
if (extent)
{
map.extent = extent;
// make sure the whole extent is visible
if (!map.extent.contains(extent))
{
map.level--;
}
}
else
{
var mapPoint:MapPoint;
if (geometry is MapPoint)
{
mapPoint = geometry as MapPoint;
}
else if (geometry is Multipoint)
{
var multipoint:Multipoint = geometry as Multipoint;
if (multipoint.points && multipoint.points.length > 0)
{
mapPoint = multipoint.points[0];
}
}
if (mapPoint)
{
// Zoom to 1/16th the size of the current extent.
// This is the same as calling map.zoomIn() four times.
map.zoom(1 / 16, mapPoint);
}
}
}
catch (error:Error){
trace(error.message);
}
}
//on fault
function qFault(info:Object, token:Object = null):void
{
trace(info.toString());
}
}else{
if (extent)
{
map.extent = extent;
// make sure the whole extent is visible
if (!map.extent.contains(extent))
{
map.level--;
}
}
else
{
var mapPoint2:MapPoint;
if (geometry is MapPoint)
{
mapPoint2 = geometry as MapPoint;
}
else if (geometry is Multipoint)
{
var multipoint2:Multipoint = geometry as Multipoint;
if (multipoint2.points && multipoint2.points.length > 0)
{
mapPoint2 = multipoint2.points[0];
}
}
if (mapPoint2)
{
// Zoom to 1/16th the size of the current extent.
// This is the same as calling map.zoomIn() four times.
map.zoom(1 / 16, mapPoint2);
}
}
}
}
Don't forget to click the top arrow (promote) and to click the Mark as answer check as shown below: