ArcGIS添加鷹眼


axMapControl1是主地圖 axMapControl2是鷹眼地圖

 

 1 private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e)
 2         {
 3             //獲取地圖當前的范圍(包絡線)
 4             IEnvelope pEnvelope = (IEnvelope)e.newEnvelope;
 5             //將鷹眼地圖設置為地理容器,再設置為活動視圖
 6             IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
 7             IActiveView pActiveView = pGraphicsContainer as IActiveView;
 8             //清除鷹眼地圖中的任何圖形元素
 9             pGraphicsContainer.DeleteAllElements();
10             //設置矩形范圍
11             IRectangleElement pRectangeEle = new RectangleElementClass();
12             IElement pElement = pRectangeEle as IElement;
13             pElement.Geometry = pEnvelope;
14 
15             //創建鷹眼圖中的紅線框
16             IRgbColor pColor = new RgbColor();
17             pColor.Red = 255;
18             pColor.Blue = 0;
19             pColor.Green = 0;
20             pColor.Transparency = 255;
21 
22             //創建線符號對象
23             ILineSymbol pOutline = new SimpleLineSymbolClass();
24             pOutline.Width = 3;
25             pOutline.Color = pColor;
26 
27             //設置顏色屬性
28             pColor = new RgbColorClass();
29             pColor.Red = 255;
30             pColor.Blue = 0;
31             pColor.Green = 0;
32             pColor.Transparency = 0;
33 
34             //設置填充符號
35             IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
36             pFillSymbol.Color = pColor;
37             pFillSymbol.Outline = pOutline;
38             
39             IFillShapeElement pFillShapeEle = pElement as IFillShapeElement;
40             pFillShapeEle.Symbol = pFillSymbol;
41 
42             pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0);
43             pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
44         }
45 
46         private void axMapControl1_OnMapReplaced(object sender, IMapControlEvents2_OnMapReplacedEvent e)
47         {
48             if (axMapControl1.LayerCount > 0)
49             {
50                 axMapControl2.Map = new MapClass();
51                 for (int i = 0; i <= axMapControl1.LayerCount - 1; i++)
52                 {
53                     axMapControl2.Map.AddLayer(axMapControl1.Map.get_Layer(i));
54                 }
55                 axMapControl2.Extent = axMapControl1.Extent;
56                 axMapControl2.Refresh();
57             }
58             //axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);
59             //axMapControl2.Refresh();
60             //axMapControl2.Extent = axMapControl2.FullExtent;
61         }
62 
63         private void axMapControl2_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
64         {
65             if (e.button == 1)
66             {
67                 IPoint pPoint = new PointClass();
68                 pPoint.PutCoords(e.mapX, e.mapY);
69                 axMapControl1.CenterAt(pPoint);
70                 axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
71             }
72         }
73 
74         private void axMapControl2_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
75         {
76             if (axMapControl2.Map.LayerCount > 0)
77             {
78                 if (e.button == 1)
79                 {
80                     IPoint pPoint = new PointClass();
81                     pPoint.PutCoords(e.mapX, e.mapY);
82                     axMapControl1.CenterAt(pPoint);
83                     axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
84                 }
85                 else
86                 {
87                     IEnvelope pEnv = axMapControl2.TrackRectangle();
88                     axMapControl1.Extent = pEnv;
89                     axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
90                 }
91 
92             }
93         }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM