Search code examples
c#shapefilesharpmap

Gis programming with SharpMap. The last layer covers the others


I'm just started with GIS programming. I want to build a simple website with a map on it. So, I choose C# and SharpMap as map lib. Everything works fine, until I add many layers from shape file. The last layer I add is the only one layer I see. This is part of my code:

SharpMap.Map map = new SharpMap.Map(outputsize);


        SharpMap.Layers.VectorLayer layCountry = new SharpMap.Layers.VectorLayer("nuoc");
        layCountry.DataSource = new SharpMap.Data.Providers.ShapeFile(@"D:\code\SharpMapDemo\SharpmapDemo\App_data\vn_tinh_region.shp", false);
        layCountry.Style.Fill = new SolidBrush(Color.Yellow);
        layCountry.Style.Outline = new Pen(Color.Black, 1);
        layCountry.Enabled = true;            
        layCountry.Style.EnableOutline = true;

        SharpMap.Layers.VectorLayer newLay = new SharpMap.Layers.VectorLayer("tinh");
        newLay.DataSource = new SharpMap.Data.Providers.ShapeFile(@"D:\code\SharpMapDemo\SharpmapDemo\App_Data\5tinh_region.shp", false);
        newLay.Style.Fill = new SolidBrush(Color.Red);
        newLay.Style.Outline = new Pen(Color.Black, 1);
        newLay.Style.EnableOutline = true;
        map.Layers.Add(newLay);
        map.Layers.Add(layCountry);

So layCountry is the only one I see. When I change the two last line to:

map.Layers.Add(layCountry);
map.Layers.Add(newLay);

newLay is the only one. Any help is appreciate. Thanks for reading this and sorry for my bad English.


Solution

  • Try semi transparent layer as below

    // Set up Plate Layer
    SharpMap.Layers.VectorLayer PlateLayer = new SharpMap.Layers.VectorLayer("PlateLayer");        
    PlateLayer.DataSource = new SharpMap.Data.Providers.ShapeFile(LayerPath + Region + "_plates.shp", false);
    Color c = Color.FromArgb(30, 100, 100, 100);
    Brush b = new SolidBrush(c);
    PlateLayer.Style.Fill = b;
    PlateLayer.Style.Outline = new Pen(Color.LightGray, 1);
    PlateLayer.Style.EnableOutline = true;
    MainMap.Layers.Add(PlateLayer);