【问题标题】:ArcObjects 10.3 Add Transparent Polygon to MapArcObjects 10.3 向地图添加透明多边形
【发布时间】:2015-10-09 18:12:02
【问题描述】:

这是我一段时间以来一直试图解决的问题,并决定寻求帮助。我正在创建一个 ESRI ArcGIS Desktop 加载项,它允许用户绘制一个多边形,然后将其添加到地图中。我能够捕获多边形并将其添加到地图中,问题是透明度。当前和默认情况下,它是 100% 不透明度和实心的。我想让它的不透明度约为 50%,以便用户可以看到它背后的数据。

这是我目前的代码:

     public static void AddPolygonToMap(IActiveView ActiveViewInstance, IGeometry NewGeo)
    {
        //Local Variable Declaration
        var fillShapeElement = default(IFillShapeElement);
        var element = default(IElement);
        var graphicsContainer = default(IGraphicsContainer);
        var simpleFilleSymbol = default(ISimpleFillSymbol);
        var newRgbColor = default(IRgbColor);
        var lineSymbol = default(ILineSymbol);

        //Use the IElement interface to set the Envelope Element's geo
        element = new PolygonElement();
        element.Geometry = NewGeo;

        //QI for the IFillShapeElement interface so that the symbol property can be set
        fillShapeElement = element as IFillShapeElement;

        //Create a new fill symbol
        simpleFilleSymbol = new SimpleFillSymbol();

        //Create a new color marker symbol of the color black;
        newRgbColor = new RgbColor();
        newRgbColor.Red = 0;
        newRgbColor.Green = 0;
        newRgbColor.Blue = 0;

        //Create a new line symbol so that we can set the width outline
        lineSymbol = new SimpleLineSymbol();
        lineSymbol.Color = newRgbColor;
        lineSymbol.Width = 2;

        //Setup the Simple Fill Symbol
        simpleFilleSymbol.Color = newRgbColor;
        simpleFilleSymbol.Style = esriSimpleFillStyle.esriSFSHollow;
        simpleFilleSymbol.Outline = lineSymbol;
        fillShapeElement.Symbol = simpleFilleSymbol;

        //QI for the graphics container from the active view allows access to basic graphics layer
        graphicsContainer = ActiveViewInstance as IGraphicsContainer;

        //Add the new element at Z order 0
        graphicsContainer.AddElement((IElement)fillShapeElement, 0);

        //Show the new graphic
        ActiveViewInstance.Refresh();
    }

我知道这在某种程度上是可能的,我确信它只是缺少一两行,但任何帮助将不胜感激。

V/r,

乔什

【问题讨论】:

标签: c# .net arcgis esri arcobjects


【解决方案1】:

这看起来是您正在创建的图形元素。图形元素不支持除 100% 透明或 0% 透明之外的透明度。以下文档对此进行了概述:

IColor.Transparency 属性 http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//001w000000nt000000

For graphic elements, 0 for transparent and 255 for opaque are the only supported values.

我希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多