Hi,I am have a little trouble trying to get the map to zoom to full extent of a query task using C#.The code i am using is as follows: QueryTask queryTask;
queryTask = new QueryTask("http://fcvmsql85/ArcGIS/rest/services/Lancs_AE_Activity_Total_Cost/MapServer/1");
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;
ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
query.Where = "GPP_Code in (" + GPP_Code + ") AND f_year = " + f_year;
query.ReturnGeometry = true;
queryTask.ExecuteAsync(query);
}
catch (Exception Ex)
{
MessageBox.Show("Page Failed: " + Ex.Message.ToString());
}
}
private void QueryTask_ExecuteCompleted(Object sender , ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
FeatureSet featureSet;
featureSet = args.FeatureSet;
if( featureSet.Features.Count > 0 )
{
ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent= featureSet.Features [0].Geometry.Extent;
// Increase Extent by value
Int32 expandVal = 500;
ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope();
displayExtent.XMin = selectedFeatureExtent.XMin - expandVal;
displayExtent.YMin = selectedFeatureExtent.YMin - expandVal;
displayExtent.XMax = selectedFeatureExtent.XMax + expandVal;
displayExtent.YMax = selectedFeatureExtent.YMax + expandVal;
MyMap1.ZoomTo(displayExtent);
}
else
{
MessageBox.Show("No f returned from query");
}
}
However, this code only allows me to set the extent of a specific id from the query task (eg [0])The section of code where is specified is here: ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent= featureSet.Features [0].Geometry.Extent;What i need is the a zoom to the extent of all of the features returned in the query task and not just ID's that are specified in the code.I suspect there is something obvious that I am missing but cant quite think what.Any advise would be extremely welcome!ThanksDave