Hi Steve,I figured out the problem. I am trying to extract the extent of the geometry and trying to pass on this info to a common .setExtent method. I have the following code which is incorrect, but can you please suggest a way to do this? I would like to keep .setExtent outside my if-else loop. Thanks, Samirfunction getStateExt(State) {
var zoomExtent;
if (State != "All India") {
var myState = State.toUpperCase();
var queryTask = new esri.tasks.QueryTask("http://nsmhpc7007:8399/arcgis/rest/services/wch3/MapServer/9");
var qState = new esri.tasks.Query();
qState.where = "name = '" + myState + "'";
qState.returnGeometry = true;
qState.outFields = ["name"];
queryTask.execute(qState);
dojo.connect(queryTask, "onComplete", function(featureSet) {
var features = featureSet.features;
stateExtent = features[0].geometry.getExtent();
var zoomExtentXmin = stateExtent.xmin - 150000;
var zoomExtentYmin = stateExtent.ymin - 75000;
var zoomExtentXmax = stateExtent.xmax + 150000;
var zoomExtentYmax = stateExtent.ymax + 75000;
zoomExtent = new esri.geometry.Extent({"xmin":zoomExtentXmin, "ymin":zoomExtentYmin, "xmax":zoomExtentXmax, "ymax":zoomExtentYmax,"spatialReference":{"wkid":102100}});
});
} else if (State == "All India") {
zoomExtent = iniExtentM.getExtent();
}
mapM.setExtent(zoomExtent);
}