Layer features in this layer set, ArcEngine图层标注源码 (转)
Posted on 2012-04-06 17:50 yushff 阅读(593) 评论(0) 编辑 收藏 举报using System;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
/// <summary>
/// (重载)图层标注
/// </summary>
/// <param name="pFeaturelayer">标注图层</param>
/// <param name="sLableField">标注字段</param>
/// <param name="pRGB">颜色</param>
/// <param name="size">大小</param>
public static void FunLabelFeatureLayer(IFeatureLayer pFeaturelayer, string sLableField, IRgbColor pRGB, int size)
{
//判断图层是否为空
if (pFeaturelayer == null)
return;
IGeoFeatureLayer pGeoFeaturelayer = (IGeoFeatureLayer)pFeaturelayer;
IAnnotateLayerPropertiesCollection pAnnoLayerPropsCollection;
pAnnoLayerPropsCollection = pGeoFeaturelayer.AnnotationProperties;
pAnnoLayerPropsCollection.Clear();
//stdole.IFontDisp pFont; //字体
ITextSymbol pTextSymbol;
//pFont.Name = "新宋体";
//pFont.Size = 9;
//未指定字体颜色则默认为黑色
if (pRGB == null)
{
pRGB = new RgbColorClass();
pRGB.Red = 0;
pRGB.Green = 0;
pRGB.Blue = 0;
}
pTextSymbol = new TextSymbolClass();
pTextSymbol.Color = (IColor)pRGB;
pTextSymbol.Size = size; //标注大小
IBasicOverposterLayerProperties pBasicOverposterlayerProps = new BasicOverposterLayerPropertiesClass();
switch (pFeaturelayer.FeatureClass.ShapeType)//判断图层类型
{
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
pBasicOverposterlayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon;
break;
case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
pBasicOverposterlayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint;
break;