3

How do you set a polygon layers transparency in DotSpatial?

I'm using vb.net in visual studio express 2013 and using a Dotspatial nugets package which has given me DotSpatial version 1.7.

Please see my code below in how i'm currently adding a new polygon shape to a dotspatial map control (mpMain), colouring it blue with a black outline.

shp = New Data.Shapefile
shp.FeatureType = Topology.FeatureType.Polygon
shp.Name = "CoveragePolygon"
shp.AddFeature(New DotSpatial.Topology.Polygon(m_coverCoords))
Dim mpl As DotSpatial.Controls.MapPolygonLayer
mpl = mpMain.Layers.Add(shp)
mpl.Symbolizer = New DotSpatial.Symbology.PolygonSymbolizer(Color.Blue, Color.Black)
4

Figured it out seconds after posting, you need to specify a colour using the Color.FromArgb method making sure you specify the desired alpha transparency then the base colour i.e.

mpl.Symbolizer = New DotSpatial.Symbology.PolygonSymbolizer(Color.FromArgb(50,Color.Blue), Color.Black)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.