AxMapControl1 is the main control, AxMapControl2 is an eagle eye control
To see the event response
1. Eagle Eye Map Resource Loading
Copy Code code as follows:
Privatevoid axmapcontrol1_onmapreplaced (object sender, Imapcontrolevents2_onmapreplacedevent e)
{
When the main map shows the control's map to be replaced, the map in the Eagle's eye follows the replacement
Axmapcontrol2.loadmxfile (Axmapcontrol1.documentfilename);
Axmapcontrol2.extent = axmapcontrol2.fullextent;
}
2. Draw the eagle eye rectangular frame
Copy Code code as follows:
private void Axmapcontrol1_onextentupdated (object sender, Imapcontrolevents2_onextentupdatedevent e)
{
Get a new range
Ienvelope penv = (ienvelope) e.newenvelope;
Igraphicscontainer Pgra = Axmapcontrol2.map as Igraphicscontainer;
Iactiveview pAv = Pgra as Iactiveview;
Clears any graphic element in the AxMapControl2 before drawing
Pgra.deleteallelements ();
Irectangleelement Prectangleele = new Rectangleelementclass ();
IElement PEle = Prectangleele as ielement;
Pele.geometry = penv;
Set the Red Line box in the Eagle's eye chart
Irgbcolor Pcolor = new Rgbcolorclass ();
pcolor.red = 255;
Pcolor.green = 0;
Pcolor.blue = 0;
Pcolor.transparency = 255;
Produces a line symbol object
Ilinesymbol poutline = new Simplelinesymbolclass ();
Poutline.width = 2;
Poutline.color = Pcolor;
Set color Properties
Pcolor = new Rgbcolorclass ();
pcolor.red = 255;
Pcolor.green = 0;
Pcolor.blue = 0;
pcolor.transparency = 0;
Set the properties of a fill symbol
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);
}
3. Achieving interaction
Copy Code code as follows:
private void Axmapcontrol2_onmousedown (object sender, Imapcontrolevents2_onmousedownevent e)
{
IPoint ppt=new Pointclass ();
Ppt.putcoords (E.MAPX, e.mapy);
Change the view scope of the main control
AxMapControl1. Centerat (pPt);
}