为贴图添加透明多边形

本文关键字:透明 多边形 添加 | 更新日期: 2023-09-27 18:03:49

这是一个问题,我一直试图解决一段时间,并决定寻求帮助。我正在创建一个ESRI ArcGIS桌面插件,允许用户绘制多边形,然后将其添加到地图中。我能够捕获多边形并将其添加到地图中,问题是透明度。目前和默认情况下,它是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

,

Josh

为贴图添加透明多边形

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

IColor。透明度的属性http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html//001 w000000nt000000

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

我希望这对你有帮助!