Select to view content in your preferred language

How to zoom-in a selected feature

832
3
10-18-2010 06:13 AM
ShaningYu
Honored Contributor
In Flex, I used the following piece of code to zoom-in a selected feature:
map.centerAt(pt);
extent = new Extent(pt.x - x_offset, pt.y - y_offset, pt.x + x_offset, pt.y + y_offset);
map.extent = extent.expand(1.1);
where the expand method is used.
In SL, my code is below:
             envelope = getEnvelope(fs);  // that returns the envelope w/ XMin, YMIN, XMAX and YMAX
             Map.Extent = envelope.Extent;
However, I could not find its expand method in the API.
If you know how to do, please help.  Thanks.
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
You can call the map's ZoomTo(Geometry geometry), where geometry is the geometry of the selected feature. If the geometry is a MapPoint, you can call the map's ZoomToResolution(double Resolution, MapPoint center) or create an extent with the MapPoint first before passing to map's  ZoomTo(Geometry geometry).
0 Kudos
ShaningYu
Honored Contributor
Jenniffer:
Thanks for your reply.  Per your advice, I wrote the piece of code like that:
fs.Features[0].Geometry.SpatialReference = _Map.SpatialReference;
  _Map.ZoomTo(fs.Features[0].Geometry);
Then it works very well.
Thanks.
0 Kudos
ShaningYu
Honored Contributor
Igore it.  Problem solved.
0 Kudos