我是靠谱客的博主 害怕人生,最近开发中收集的这篇文章主要介绍ArcEngine设置有牵引线的标注,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

在ArcGIs中很容易就能设置带有牵引线的标注。


在ArcEngine中实现方法也很简单。如下:

        /// <summary>
        /// 设置有引线的标注
        /// </summary>
        /// <param name="IN_FeatureLayer">要标注的图层</param>
        /// <param name="IN_Axmapcontrol">显示控件</param>
        private void PRV_SetLabelWithCallout(IFeatureLayer IN_FeatureLayer,AxMapControl IN_Axmapcontrol)
        {
            //设定地图标注引擎
            IAnnotateMap Temp_AnnotateMap = new AnnotateMapClass();
            IN_Axmapcontrol.Map.AnnotationEngine = Temp_AnnotateMap;
            //标注集合
            IGeoFeatureLayer Temp_AnnotationLayer = IN_FeatureLayer as IGeoFeatureLayer;
            IAnnotateLayerPropertiesCollection Temp_AllAnnoProps;
            Temp_AllAnnoProps = Temp_AnnotationLayer.AnnotationProperties;
            Temp_AllAnnoProps.Clear();//清理已有标注属性
            IAnnotateLayerProperties Temp_Anno = PRV_SetPropertiesWithCallout(IN_FeatureLayer, "[OBJECTID]", IN_Axmapcontrol);
            Temp_AllAnnoProps.Add(Temp_Anno);
            IN_Axmapcontrol.AddLayer(IN_FeatureLayer as ILayer);
        }

用到的函数:

        /// <summary>
        /// 设有引线的标注参数
        /// </summary>
        /// <param name="IN_FeatureLayer">要标注的图层</param>
        /// <param name="IN_ClassExpression">标注表达式</param>
        /// <param name="IN_Axmapcontrol">显示控件</param>
        /// <returns>标注参数</returns>
        private IAnnotateLayerProperties PRV_SetPropertiesWithCallout(IFeatureLayer IN_FeatureLayer, string IN_ClassExpression,AxMapControl IN_Axmapcontrol)
        {
            //标注引擎
            ILabelEngineLayerProperties2 Temp_LabelEngine2 = new LabelEngineLayerPropertiesClass();
            IBasicOverposterLayerProperties4 Temp_BasicOverPoster = new BasicOverposterLayerPropertiesClass();
            //表达式
            Temp_LabelEngine2.Expression = IN_ClassExpression;
            //引线
            ILineCallout Temp_Callout = new LineCalloutClass();
            //引线样式
            Temp_Callout.Style = esriLineCalloutStyle.esriLCSMidpoint;
            Temp_Callout.LeaderTolerance = 1;
            //将外框都设为null,这样就只有引线了
            Temp_Callout.Border = null;
            Temp_Callout.AccentBar = null;
            Temp_Callout.Gap = 10;
            //引线类型,这里为点状线
            ISimpleLineSymbol Temp_LineSymbol = new SimpleLineSymbolClass();
            Temp_LineSymbol.Style = esriSimpleLineStyle.esriSLSDot;
            Temp_Callout.LeaderLine = Temp_LineSymbol;
            //文字符号设定
            IFormattedTextSymbol Temp_TextSymbol = new TextSymbolClass();
            //文字颜色
            IRgbColor Temp_RGB = new RgbColorClass();
            Temp_RGB.Red = 0;
            Temp_RGB.Green = 0;
            Temp_RGB.Blue = 0;
            //文字字体与字号
            Temp_TextSymbol = new TextSymbolClass();
            Temp_TextSymbol.Color = (IColor)Temp_RGB;
            Temp_TextSymbol.Size = 18;
            //需要引用stdole.dll
            stdole.IFontDisp Temp_Font = new stdole.StdFontClass() as stdole.IFontDisp;
            Temp_Font.Name = "Arial";
            Temp_TextSymbol.Background = Temp_Callout as ITextBackground;
            Temp_TextSymbol.Font = Temp_Font;
            Temp_LabelEngine2.Symbol = Temp_TextSymbol as ITextSymbol;
            //标注放置方式
            switch (IN_FeatureLayer.FeatureClass.ShapeType)//判断图层类型
            {
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                    Temp_BasicOverPoster.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
                    Temp_BasicOverPoster.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysHorizontal;
                    break;
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                    Temp_BasicOverPoster.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
                    Temp_BasicOverPoster.PointPlacementMethod = esriOverposterPointPlacementMethod.esriAroundPoint;
                    break;
                case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                    Temp_BasicOverPoster.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
                    break;
            }
            Temp_LabelEngine2.BasicOverposterLayerProperties = Temp_BasicOverPoster as IBasicOverposterLayerProperties;
            //设定标注
            IMapOverposter Temp_MapPos = IN_Axmapcontrol.Map as IMapOverposter;
            IOverposterProperties Temp_OverPoster = Temp_MapPos.OverposterProperties;
            IAnnotateLayerProperties Temp_AnnoPClass = Temp_LabelEngine2 as IAnnotateLayerProperties;
            (IN_FeatureLayer as IGeoFeatureLayer).DisplayAnnotation = true;
            return Temp_AnnoPClass;
        }

效果如图:


最后

以上就是害怕人生为你收集整理的ArcEngine设置有牵引线的标注的全部内容,希望文章能够帮你解决ArcEngine设置有牵引线的标注所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部