//if (_firstZoom) //{ // MyMap.ZoomToResolution(MyMap.Resolution / 6, pt); // _firstZoom = false; //} //else // MyMap.PanTo(pt); centerAndZoom(MyMap, pt, MyMap.MinimumResolution * 4);
private void centerAndZoom(ESRI.ArcGIS.Client.Map map, ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint, double resolution) { double ratio = 1.0; if (map.Resolution != 0.0) ratio = resolution / map.Resolution; if (ratio == 1.0) map.PanTo(mapPoint); else { ESRI.ArcGIS.Client.Geometry.MapPoint mapCenter = map.Extent.GetCenter(); double X = (mapPoint.X - ratio * mapCenter.X) / (1 - ratio); double Y = (mapPoint.Y - ratio * mapCenter.Y) / (1 - ratio); map.ZoomToResolution(resolution, new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y)); } }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.