arcEngine经典代码-添加气泡提示框(标注,文本,)

  private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
       
            if (i >= 3)//测试目的
                return;
            i++;

            ITextElement te = createTextElement(e.mapX,e.mapY,"魁x");
            axMapControl1.ActiveView.GraphicsContainer.AddElement(te as IElement, 1);
            axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);

    
        }
        int i;

        public IBalloonCallout createBalloonCallout(double x, double y)
        {
            IRgbColor rgb = new RgbColorClass();
            {
                rgb.Red = 255;
                rgb.Green = 255;
                rgb.Blue = 200;

            }
            ISimpleFillSymbol sfs = new SimpleFillSymbolClass();
            {
                sfs.Color = rgb;
                sfs.Style = esriSimpleFillStyle.esriSFSSolid;
            }

            IPoint p = new PointClass();
            {
                p.PutCoords(x, y);
            }

            IBalloonCallout bc = new BalloonCalloutClass();
            {
                bc.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                //
                bc.Symbol = sfs;
                //
                bc.LeaderTolerance = 10;
                //1

                bc.AnchorPoint = p;
            }

            return bc;
        }

        public ITextElement createTextElement(double x, double y, string text)
        {
            IBalloonCallout bc = createBalloonCallout(x, y);
           
            IRgbColor rgb = new RgbColorClass();
            {
                //rgb.Red = 255;
                rgb.Green = 255;
            }
            ITextSymbol ts = new TextSymbolClass();
            {
                ts.Color = rgb;
            }

            IFormattedTextSymbol fts = ts as IFormattedTextSymbol;
            {
                fts.Background = bc as ITextBackground;
            }
            //fts.Size = 8;
            ts.Size = 8;

            IPoint point = new PointClass();
            {
                double width = axMapControl1.Extent.Width / 13;
                double height = axMapControl1.Extent.Height / 20;
                point.PutCoords(x + width, y + height);
            }

            ITextElement te = new TextElementClass();
            //IMarkerElement me = new MarkerElementClass();
            {
                te.Symbol = ts;
                //ts.Text = text;
                te.Text = text;
            }

            IElement e = te as IElement;
            {
                e.Geometry = point;
            }
            return te;

        }
    }

posted @ 2008-08-11 18:56 风过 无痕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
当然可以!以下是一个使用 ArcGIS Engine 添加文字的示例代码: ```csharp using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Display; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.Controls; using ESRI.ArcGIS.SystemUI; // 创建一个添加文字的方法 public void AddText(IActiveView activeView, string text, IPoint point) { // 创建文本元素 ITextElement textElement = new TextElementClass(); // 设置文本内容 textElement.Text = text; // 设置文本颜色 IRgbColor textColor = new RgbColorClass(); textColor.Red = 0; textColor.Green = 0; textColor.Blue = 0; ITextSymbol textSymbol = new TextSymbolClass(); textSymbol.Color = textColor; // 设置文本字体和大小 IFontDisp font = new StdFont() as IFontDisp; font.Name = "Arial"; font.Size = 12; textSymbol.Font = font; // 创建文本元素的元素对象 textElement.Symbol = textSymbol; // 创建一个元素容器并添加文本元素 IGraphicsContainer graphicsContainer = activeView as IGraphicsContainer; graphicsContainer.AddElement(textElement, 0); // 刷新地图视图以显示添加文本元素 activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } // 调用添加文字方法的示例代码 public void AddTextExample(AxMapControl mapControl) { // 获取当前地图视图的活动视图 IActiveView activeView = mapControl.ActiveView; // 创建一个坐标点来确定文本位置 IPoint point = new PointClass(); point.X = 100; // 文本的 X 坐标 point.Y = 100; // 文本的 Y 坐标 // 调用添加文字方法,传入文本内容和坐标点 AddText(activeView, "Hello, World!", point); } ``` 你可以将上述代码添加ArcGIS Engine 的应用程序中,并调用 `AddTextExample()` 方法来添加指定位置的文本。请注意,这只是一个简单的示例,你可以根据自己的需求进行修改和扩展。希望对你有帮助!如果你还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值