case "放大": MyDrawObject.IsEnabled = true; _toolMode = "zoomin"; break; case "缩小": MyDrawObject.IsEnabled = true; _toolMode = "zoomout"; break;
void MyDrawObject_DrawComplete(object sender,DrawEventArgs e) { if (_toolMode == "zoomin") { MyMap.ZoomTo(e.Geometry as ESRI.ArcGIS.Client.Geometry.Envelope); } else if (_toolMode == "zoomout") { Envelope currentExtent = MyMap.Extent; Envelope zoomBoxExtent = e.Geometry as Envelope; MapPoint zoomBoxCenter = zoomBoxExtent.GetCenter(); double whRatioCurrent = currentExtent.Width / currentExtent.Height; double whRatioZoomBox = zoomBoxExtent.Width / zoomBoxExtent.Height; Envelope newEnv = null; if (whRatioZoomBox > whRatioCurrent) // use width { double mapWidthPixels = MyMap.Width; double multiplier = currentExtent.Width / zoomBoxExtent.Width; double newWidthMapUnits = currentExtent.Width * multiplier; newEnv = new Envelope(new MapPoint(zoomBoxCenter.X - (newWidthMapUnits / 2),zoomBoxCenter.Y),new MapPoint(zoomBoxCenter.X + (newWidthMapUnits / 2),zoomBoxCenter.Y)); } else // use height { double mapHeightPixels = MyMap.Height; double multiplier = currentExtent.Height / zoomBoxExtent.Height; double newHeightMapUnits = currentExtent.Height * multiplier; newEnv = new Envelope(new MapPoint(zoomBoxCenter.X,zoomBoxCenter.Y - (newHeightMapUnits / 2)),new MapPoint(zoomBoxCenter.X,zoomBoxCenter.Y + (newHeightMapUnits / 2))); } if (newEnv != null) MyMap.ZoomTo(newEnv); } }
MyDrawObject = new Draw(MyMap) { FillSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.FillSymbol,DrawMode = DrawMode.Rectangle }; MyDrawObject.DrawComplete += new EventHandler<DrawEventArgs>(MyDrawObject_DrawComplete);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。