axMapControl1是主控件,axMapControl2是鷹眼控件
要看清楚事件響應
1.鷹眼地圖資源載入
{
//當主地圖顯示控件的地圖更換時,鷹眼中的地圖也跟隨更換
axMapControl2.LoadMxFile(axMapControl1.DocumentFilename);
axMapControl2.Extent = axMapControl2.FullExtent;
}
{
// 得到新范圍
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);
}
{
IPoint pPt=new PointClass ();
pPt.PutCoords (e.mapX ,e.mapY );
//改變主控件的視圖范圍
axMapControl1 .CenterAt (pPt );
}
新聞熱點
疑難解答