阅读:2668回复:5
在mapcontrol中如何实现鹰眼功能?
在mapcontrol中如何实现鹰眼功能?
|
|
1楼#
发布于:2005-02-03 11:53
<P>朋友下面的代码,也许可以帮你! </P><P>/// <summary>
/// 根据主地图的边界值,改变当前地图的填充元素位置和大小 /// </summary> public void DrawRectangle() { if( axMapControl.LayerCount > 0 ) { // 删除地图中的所有绘制元素 axMapControl.ActiveView.GraphicsContainer.DeleteAllElements(); IElement pElement = new RectangleElementClass(); IFillShapeElement pFillShapeElement = pElement as IFillShapeElement; pFillShapeElement.Symbol = pFillSymbol; pElement.Geometry = pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds; // 添加矩形元素到当前地图 axMapControl.ActiveView.GraphicsContainer.AddElement( pElement, 0); axMapControl.CtlRefresh( esriViewDrawPhase.esriViewGraphics, pElement, axMapControl.Extent ); } }</P><P>private void axMapControl_OnMouseDown(object sender, ESRI.ArcObjects.AxMapControl.IMapControlEvents2_OnMouseDownEvent e) { if( axMapControl.LayerCount > 0 ) { IEnvelope pEnv = axMapControl.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds; axMapControl.ActiveView.GraphicsContainer.DeleteAllElements(); IEnvelope pEnvelope = new EnvelopeClass(); IElement pElement = new RectangleElementClass(); IFillShapeElement pFillShapeElement = pElement as IFillShapeElement; pFillShapeElement.Symbol = pFillSymbol; pEnvelope = axMapControl.TrackRectangle(); if( pEnvelope.IsEmpty || pEnvelope.Width == 0.0 || pEnvelope.Height == 0.0) { // 移动当前主地图显示区域矩形的坐标调整 IEnvelope pEnvelope1 = hook.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds; pEnvelope.XMin = e.mapX - (pEnvelope1.XMax - pEnvelope1.XMin) / 2; pEnvelope.XMax = e.mapX + (pEnvelope1.XMax - pEnvelope1.XMin) / 2; pEnvelope.YMin = e.mapY - (pEnvelope1.YMax - pEnvelope1.YMin) / 2; pEnvelope.YMax = e.mapY + (pEnvelope1.YMax - pEnvelope1.YMin) / 2; } else { IEnvelope pEnvelope1 = hook.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds; // 计算主地图显示区域矩形宽度与高度的比例 double btWidth = pEnvelope1.Width / pEnvelope1.Height; // 判断划出矩形的边界值调整 if( pEnvelope.Width > pEnvelope.Height * btWidth ) pEnvelope.YMin = pEnvelope.YMax - pEnvelope.Width / btWidth; else pEnvelope.XMax = pEnvelope.XMin + pEnvelope.Height * btWidth; } </P><P> pElement.Geometry = pEnvelope; // 添加矩形元素到当前地图 axMapControl.ActiveView.GraphicsContainer.AddElement( pElement, 0); axMapControl.CtlRefresh( esriViewDrawPhase.esriViewGraphics, pElement, axMapControl.Extent );</P><P> // 改变主地图显示区域 hook.ActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds = pEnvelope; hook.ActiveView.Refresh(); } }</P> |
|
|
2楼#
发布于:2005-02-03 14:41
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em05.gif" />
|
|
|
3楼#
发布于:2005-02-20 16:34
<img src="images/post/smile/dvbbs/em06.gif" />
|
|
4楼#
发布于:2005-02-23 08:45
<img src="images/post/smile/dvbbs/em01.gif" />
|
|
5楼#
发布于:2005-02-23 11:35
<P>小弟我是新来的,看了很受益!谢谢!</P>
|
|