Select to view content in your preferred language

Find tool (how to add a "zoom to" function)

4220
3
12-06-2011 01:08 PM
JerryBiedenbender
New Contributor
I am using the find tool located at http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Find and its great but I need to be able to zoom to the feature that it found. Either an auto zoom or a click to zoom. Does anyone know how to add this function to the tool?


Thanks,
Jerry
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
With the sample you pointed out, you can get autozoom by adding this code in find.xaml.cs:

......
graphicsLayer.Graphics.Add(graphic);
 
// Zoom to selected graphic
var geometry = graphic.Geometry;
if (geometry.Extent.Width == 0 && geometry.Extent.Height == 0)
{
// Zoom to point is not supported -> need to expand the geometry (we might also just Pan)
var center = geometry.Extent.GetCenter();
double size = MyMap.MinimumResolution == 0 ? 1000 : MyMap.ActualWidth * MyMap.MinimumResolution * 4.0;
geometry = new ESRI.ArcGIS.Client.Geometry.Envelope(center.X - size / 2, center.Y - size / 2, center.X + size / 2, center.Y + size / 2);
}
MyMap.ZoomTo(geometry);
......
0 Kudos
Asgharkhan
Occasional Contributor

Thanks !

What I am Looking For

can i add a label which show how much record found in data grid?

0 Kudos
JerryBiedenbender
New Contributor
Thanks that works perfectly

Jerry
0 Kudos