下面的代码实现在PageLayoutControl中,当单击时,在该点击坐标处显示一个图片。
//Get the IRGBColor interface
IRgbColor color = new RgbColorClass();
//Set the color properties
color.RGB = 255;
color.Transparency = 255;
// 获取PageLayoutControl中焦点地图的IActiveView对象
IActiveView activeView =
axPageLayoutControl1.ActiveView.FocusMap as IActiveView;
//Create a point
IPoint ax_point = new PointClass();
//ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent e
//从屏幕x,y位置得到地图坐标
ax_point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
//Create a new pictureMarker symbol
IPictureMarkerSymbol picMSymbol = new PictureMarkerSymbolClass();
picMSymbol.Size = 10; //图片大小
string pPicturePath = Application.StartupPath + "//ESRI_LOGO.bmp"; //图片位置和文件名
picMSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, pPicturePath); //获取图片内容
picMSymbol.BitmapTransparencyColor = color;
//Create a new pictureMarker Element
IMarkerElement myMElement = new MarkerElementClass();
myMElement.Symbol = picMSymbol as IMarkerSymbol;
//QI for IElement
IElement element = myMElement as IElement;
//Set the elements geometry
element.Geometry = ax_point;
//Add the element to the graphics container
activeView.GraphicsContainer.AddElement(element, 0);
//Refresh the graphics
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);