c#+argis92 在点击坐标处插入一图片

12 篇文章 1 订阅

下面的代码实现在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); 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值