This project is read-only.

map shapefile change color randomly

Jan 13, 2014 at 2:01 PM
i have this code
     Dim wgs84 As ProjectionInfo = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984
        uxMap.Projection = wgs84

        uxMap.AddLayer("Data\countries.shp")

        uxMap.CollisionDetection = True
        uxMap.ZoomToMaxExtent()
        
        uxMap.FunctionMode = DotSpatial.Controls.FunctionMode.Pan
ho to set my color?
outline, background?
tnx
Jan 13, 2014 at 5:43 PM
this happen to anyone?
every time I run the program the map changes color as it wants
Aug 16, 2014 at 12:13 AM
Yes, I meet the same question.

Rambaldi, have you found the ways to solve it?
Aug 18, 2014 at 9:04 AM
It's normal that layers get a random color when they are added to the map.

Change
 uxMap.AddLayer("Data\countries.shp")
to
Dim featureLayer as IFeatureLayer = ctype( uxMap.AddLayer("Data\countries.shp"), IFeatureLayer)
and add
Dim PS As New PolygonSymbolizer
PS.SetFillColor(Drawing.Color.Beige)
PS.SetOutline(Drawing.Color.Black, 1)
featureLayer.Symbolizer = PS
Then the layer has the same outline and color whenever you add it.

Have a look at the Getting Started Guide if you want to know what else you can do with the Symbolizer.

If you add the same layers whenever you load your program you could also save them as Project file (*.dspx) and load this file on opening the program.
Marked as answer by jany_ on 9/9/2014 at 1:26 AM