您的位置:首页 > 编程语言 > C#

C#制作Arcgis Engine鹰眼全过程

2010-04-15 10:23 155 查看
1. axMapControl1是主控件,axMapControl2是鹰眼控件

1.鹰眼地图资源载入

3.  private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)

4.          {

5.              //当主地图显示控件的地图更换时,鹰眼中的地图也跟随更换

6.             axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);

7.              axMapControl2.Extent = axMapControl2.FullExtent;

8.          }

9.  2.绘制鹰眼矩形框

10.private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)

11.        {

12.            // 得到新范围

13.           IEnvelope pEnv = (IEnvelope)e.newEnvelope;

14.           IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer;

15.           IActiveView pAv = pGra as IActiveView;

16.           //在绘制前,清除axMapControl2中的任何图形元素

17.           pGra.DeleteAllElements();

18.         IRectangleElement pRectangleEle = new RectangleElementClass();

19.          IElement pEle = pRectangleEle as IElement;

20.          pEle.Geometry = pEnv;

21.          //设置鹰眼图中的红线框

22.          IRgbColor pColor = new RgbColorClass();

23.           pColor.Red = 255;

24.           pColor.Green = 0;

25.          pColor.Blue = 0;

26.           pColor.Transparency = 255;

27.           //产生一个线符号对象

28.           ILineSymbol pOutline = new SimpleLineSymbolClass();

29.           pOutline.Width = 2;

30.           pOutline.Color = pColor;

31.            //设置颜色属性

32.           pColor = new RgbColorClass();

33.           pColor.Red = 255;

34.            pColor.Green = 0;

35.           pColor.Blue = 0;

36.            pColor.Transparency = 0;

37.            //设置填充符号的属性

38.            IFillSymbol pFillSymbol = new SimpleFillSymbolClass();

39.            pFillSymbol.Color = pColor;

40.            pFillSymbol.Outline = pOutline;

41.            IFillShapeElement pFillShapeEle = pEle as IFillShapeElement;

42.            pFillShapeEle.Symbol = pFillSymbol;

43.           pGra.AddElement((IElement)pFillShapeEle, 0);

44.           pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

45.        }

46.3. 实现互动

47.   private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)

48.        {

49.           IPoint pPt=new PointClass ();

50.           pPt.PutCoords (e.mapX ,e.mapY );

51.            //改变主控件的视图范围

52.          axMapControl1 .CenterAt (pPt );

53.        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: