• Layer features in this layer set, ArcEngine图层标注源码 (转)


    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;
    case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
    pBasicOverposterlayerProps.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline;
    break;
    }

    ILabelEngineLayerProperties pLabelEnginelayerProps = new LabelEngineLayerPropertiesClass();
    pLabelEnginelayerProps.Expression = "[" + sLableField + "]";
    pLabelEnginelayerProps.Symbol = pTextSymbol;
    pLabelEnginelayerProps.BasicOverposterLayerProperties = pBasicOverposterlayerProps;

    pAnnoLayerPropsCollection.Add((IAnnotateLayerProperties)pLabelEnginelayerProps);
    pGeoFeaturelayer.DisplayAnnotation = true;//很重要,必须设置
    //axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
    }
  • 相关阅读:
    MySQL主从复制与主主复制
    Go语言mgo
    beego07----web博客
    mongo14-----group,aggregate,mapReduce
    mongo13----application set与分片结合
    mongo12---手动预先分片
    TCP/IP详解学习笔记(4)-ICMP协议,ping和Traceroute
    TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议
    TCP/IP详解学习笔记(2)-数据链路层
    TCP/IP详解学习笔记(1)-基本概念
  • 原文地址:https://www.cnblogs.com/yuxuetaoxp/p/2435043.html
Copyright © 2020-2023  润新知