ArcEngine中鷹眼實現
阿新 • • 發佈:2018-12-12
private void axMapControl1_OnMapReplaced_1(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e) { this.axMapControl2.Map = new MapClass(); // 新增主地圖控制元件中的所有圖層到鷹眼控制元件中 for (int i = 1; i <= this.axMapControl1.LayerCount; i++) { this.axMapControl2.AddLayer(this.axMapControl1.get_Layer(this.axMapControl1.LayerCount - i)); } // 設定 MapControl 顯示範圍至資料的全域性範圍 this.axMapControl2.Extent = this.axMapControl1.FullExtent; // 重新整理鷹眼控制元件地圖 this.axMapControl2.Refresh(); } private void axMapControl1_OnExtentUpdated_1(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e) { // 得到新範圍 IEnvelope pEnv = (IEnvelope)e.newEnvelope; IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer; IActiveView pAv = pGra as IActiveView; // 在繪製前,清除 axMapControl2 中的任何圖形元素 pGra.DeleteAllElements(); IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pEle = pRectangleEle as IElement; pEle.Geometry = pEnv; // 設定鷹眼圖中的紅線框 IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 255; // 產生一個線符號物件 ILineSymbol pOutline = new SimpleLineSymbolClass(); pOutline.Width = 2; pOutline.Color = pColor; // 設定顏色屬性 pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 0; // 設定填充符號的屬性 IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = pColor; pFillSymbol.Outline = pOutline; IFillShapeElement pFillShapeEle = pEle as IFillShapeElement; pFillShapeEle.Symbol = pFillSymbol; pGra.AddElement((IElement)pFillShapeEle, 0); // 重新整理 pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }