ArcEngine开发鹰眼实现问题

时间:2024-01-03 21:57:44

在网上百度一下有关AE鹰眼实现的代码,基本是一样的,可问题是好多代码自己运行起来鹰眼却总是加不进地图。住视图axMapControl1.OnMapReplaced(),axMapControl1.OnExtentUpdated(),axMapControl2.OnMouseDown(),axMapControl2.OnMouseMove()在这几个事件绑定的委托方法里写代码,能够实现鹰眼所必须的功能。问题看似简单,代码也不难理解,可往往别人的代码到我们这里却总是会出现很多bug,问题是什么,我现在也不知道,为什么鹰眼地图总是加不进去,按理说代码改来改去都觉得问题不大应该可以实现,可就是无法显示,蛋疼的很。这也就是我们看别人代码思路感觉都对着,可往往在我们实际去做,总是会出现各种各样的不如人意。哎,不说了,把那经典的代码贴下来,那天返回来再看吧。现在我只有用比较笨的硬拷贝方法来实现鹰眼的显示联动问题了。

        private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{
if (axMapControl2.Map.LayerCount > )
{
if (e.button == )
{
IPoint pPt = new PointClass();
pPt.X = e.mapX;
pPt.Y = e.mapY;
IEnvelope pEnvelope = axMapControl1.Extent as IEnvelope;
pEnvelope.CenterAt(pPt);
axMapControl1.Extent = pEnvelope;
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); }
else if (e.button == )
{
IEnvelope pEnvelope = axMapControl2.TrackRectangle();
axMapControl1.Extent = pEnvelope;
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
}
}
} private void axMapControl2_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
{
if (e.button != )
return;
IPoint pPt = new PointClass();
pPt.X = e.mapX;
pPt.Y = e.mapY;
axMapControl1.CenterAt(pPt);
axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
} private void axMapControl1_OnMapReplaced(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMapReplacedEvent e)
{
if (axMapControl1.LayerCount > )
{
//IMap pMap = axMapControl1.Map;
axMapControl2.Map = new MapClass(); for (int i = ; i <= axMapControl1.Map.LayerCount - ; i++)
{
//axMapControl2.Map.AddLayer(pMap.get_Layer(i));
axMapControl2.AddLayer(axMapControl1.get_Layer(i));
}
}
axMapControl2.Extent = axMapControl1.FullExtent;
axMapControl2.Refresh();
} private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e)
{
IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer;
IActiveView pAV = pGraphicsContainer as IActiveView;
pGraphicsContainer.DeleteAllElements();
IRectangleElement pRecElement = new RectangleElementClass();
IElement pEle = pRecElement as IElement;
IEnvelope pEnv;
pEnv = e.newEnvelope as IEnvelope;
IRgbColor pColor = new RgbColorClass();
pColor.Red = ;
pColor.Green = ;
pColor.Blue = ;
pColor.Transparency = ;
//产生一个线符号对象
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
pLineSymbol.Width = ;
pLineSymbol.Color = pColor;
//设置填充符号属性
IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
//设置透明颜色
pColor.Transparency = ;
pFillSymbol.Color = pColor;
pFillSymbol.Outline = pLineSymbol;
IFillShapeElement pFillShapeElement = pRecElement as IFillShapeElement;
pFillShapeElement.Symbol = pFillSymbol;
pGraphicsContainer.AddElement(pEle, ); axMapControl2.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}

why it doesn't run ?