概述
方法一:
主要是使用了ISymbolCollectionElement接口设置了Feature的各种属性
IGeometry pointGeometry 这个几何对象应该是一个IPoint;
esriTextHorizontalAlignment 与 esriTextVerticalAlignment指示这个point在Annotation元素(一个面Polygon)的哪个位置,借此确定放置位置。
ISymbolCollectionElement或者IFormattedTextSymbol还有更多的属性可以设置(本文不做补充)
但是此方法没法设置文本标注的旋转角(方法二可以)
public void CreateAnnotationFeature(IGeometry pointGeometry,string text,string fontName,double fontSize,esriTextHorizontalAlignment horizontalAlignment,
esriTextVerticalAlignment verticalAlignment)
{
IFeature feature = featureClass.CreateFeature();
ISymbolCollectionElement symbolCollectionElement = new TextElementClass();
symbolCollectionElement.FontName = fontName;
symbolCollectionElement.Size = fontSize;
symbolCollectionElement.Text = text;
symbolCollectionElement.HorizontalAlignment = horizontalAlignment;
symbolCollectionElement.VerticalAlignment = verticalAlignment;
symbolCollectionElement.Geometry = pointGeometry;
IElement element = symbolCollectionElement as IElement;
IAnnotationFeature2 annotationFeature2 = feature as IAnnotationFeature2;
annotationFeature2.Annotation =element;
annotationFeature2.Status = esriAnnotationStatus.esriAnnoStatusPlaced;
feature.Store();
}
方法二:
主要使用IFormattedTextSymbol接口的方案
这种方法可以设置的参数好像多一些 fmtTextSymb.Angle 这个就是旋转角 传入的参数为角度
private void AddAnno(IFeatureClass featClass, IPoint pt, string textString)
{
IFeature feature = featClass.CreateFeature();
var annoClass = featClass.Extension as IAnnoClass;
IFontDisp font = new StdFontClass() as IFontDisp;
font.Name = "Arial";
font.Bold = true;
// font.Size = 30;
// load in some reasonable default values..
IFormattedTextSymbol fmtTextSymb = new TextSymbolClass();
fmtTextSymb.Font = font;
fmtTextSymb.Size = 30;
fmtTextSymb.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom;
fmtTextSymb.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
fmtTextSymb.Angle = 0;
fmtTextSymb.CharacterSpacing = 100;
fmtTextSymb.CharacterWidth = 100;
fmtTextSymb.FlipAngle = 90;
fmtTextSymb.Leading = 0;
fmtTextSymb.WordSpacing = 100;
fmtTextSymb.Text = textString; // my special text value..
ITextElement textElement = new TextElementClass();
textElement.Symbol = fmtTextSymb;
textElement.Text = textString;
IElement element = textElement as IElement;
element.Geometry = pt;
(feature as IAnnotationFeature2).Annotation = element;
feature.Store();
}
}
参考:https://www.cnblogs.com/yzhyingcool/p/11518652.html
最后
以上就是还单身香水为你收集整理的Arcgis engine 创建文本标注要素添加到表方法一:方法二:的全部内容,希望文章能够帮你解决Arcgis engine 创建文本标注要素添加到表方法一:方法二:所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复