Zoom to Selected Record & Scale Range for Graphic and feature Layer

3892
3
06-19-2011 10:11 PM
MuhammadWaqar_ul_islam
New Contributor III
i have selected records in slData:DataGrid through query
i want to zoom to selected record in data grid (required code C#)

and
how to define  Scale range for  Graphic and feature layer
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor

i want to zoom to selected record in data grid


You can call Map.ZoomTo  with the geometry extent of your selected graphic.
This is working well if your geometry is a line or a polygon.
If it's a point, you have to create an envelope around the point (with a size depending on the zoom level you are expecting) and call ZoomTo with this envelope.
0 Kudos
angelasuch
New Contributor

please explain how to  'create an envelope around the point'. 

0 Kudos
DominiqueBroux
Esri Frequent Contributor

please explain how to  'create an envelope around the point'

Something like:

var env = new Envelope(point.X - size/2, point.Y - size/2, point.X + size/2, point.Y + size/2);

env.SpatialReference = point.SpatialReference;

0 Kudos