Polygon Opacity (how to set?)

Dec 29, 2010 at 6:55 PM

I'm trying to set a polygon feature layer opacity with the code below but it doesn't seem to be working. Any help would be appreciated.

private void setPolygonColor(ref IMapFeatureLayer myLayer, Color clr, Color outLine, double width, float opacity)
{
//Create the simple pattern with opacity
SimplePattern sp = new SimplePattern(clr);
sp.Opacity = opacity;

//Create the symbolizer with the input values
PolygonSymbolizer poly = new PolygonSymbolizer(clr, outLine, width);
poly.Patterns.Add(sp);

//Set the map Symbolizer
myLayer.Symbolizer = poly;
}

Developer
Dec 29, 2010 at 8:28 PM

Future discussion should move to the issue for this topic.

Ted

 

Apr 1, 2011 at 11:34 AM
Edited Apr 1, 2011 at 11:34 AM

I meet this question too. can anyone give an answer.

 

Editor
Apr 1, 2011 at 11:48 AM

Friends, if I am not sure you can use a MapPolygonLayer in place of IMapFeatureLayer.

Hope it serves you.

Francisco J.

Apr 1, 2011 at 11:56 AM
Edited Apr 1, 2011 at 12:05 PM

thanks. I used MapPolygonLayer ,but I don't konw how to set the opacity.

 Can you give me an example?





--

曹思聪 欢迎光临 乐学博客

Apr 1, 2011 at 2:42 PM

I get it,this will work well.

thanks geofran80.

 private void setPolygonColor(ref MapPolygonLayer myLayer, Color clr, Color outLine, double width, float opacity)
        {
            //Create the simple pattern with opacity
            SimplePattern sp = new SimplePattern(clr);
            sp.Opacity = opacity;

            //Create the symbolizer with the input values
            PolygonSymbolizer poly = new PolygonSymbolizer(clr, outLine, width);
            poly.Patterns.Clear();
            poly.Patterns.Add(sp);

            //Set the map Symbolizer
            myLayer.Symbolizer = poly;
        }

Editor
Apr 1, 2011 at 4:24 PM

Sorry for not answer your question, I didn't see your second cuestion.

Is great that you can make it using this feature.

This sample code will be useful for many users.

Note. You can download the tutorials from the Documentation > DotSpatial.NET Tutorials where you can find many different case of use.

Regards.

Francisco J.