Simple polygon problem

Feb 3, 2012 at 12:24 PM

Hi, i'am trying to, show a simple polygon with MapSui silverlight demo code . but i can't get it to work :-(

Polygon polygontest = new Polygon();
polygontest.ExteriorRing.Vertices.Add(new SharpMap.Geometries.Point(0, 0));
polygontest.ExteriorRing.Vertices.Add(new SharpMap.Geometries.Point(10, 0));
polygontest.ExteriorRing.Vertices.Add(new SharpMap.Geometries.Point(10, 15));
polygontest.ExteriorRing.Vertices.Add(new SharpMap.Geometries.Point(0, 10));
SharpMap.Layers.Layer mylayer = new SharpMap.Layers.Layer("myTest");
mylayer.DataSource = new SharpMap.Providers.MemoryProvider(polygontest);
map.Layers.Add(mylayer);

what am i doing wrong

 

 

 

 

Coordinator
Feb 3, 2012 at 4:53 PM

Hi there. A layers has an array of styles. Default there this array is empty. So there is no style, no rendering. I just tested code below and will add it too the samples of the project. 

I would like to add a default style to the array on construction, but currently there is no base style that would work for all layers (a LabelLayer needs a LayerStyle) so I did'nt add one. I think I should derive LayerStyle and all others from some generic base style. 

 

public static ILayer AddLayerWithOnePolygon() {           

    var polygon = new Polygon();

    polygon.ExteriorRing.Vertices.Add(new Point(0, 0));

    polygon.ExteriorRing.Vertices.Add(new Point(0, 1000000));

    polygon.ExteriorRing.Vertices.Add(new Point(1000000, 1000000));

    polygon.ExteriorRing.Vertices.Add(new Point(1000000, 0));

    polygon.ExteriorRing.Vertices.Add(new Point(0, 0));

    var layer = new Layer("LayerWithPolygon");

    layer.DataSource = new Providers.MemoryProvider(polygon);    

    layer.Styles.Add(new VectorStyle());           

    return layer;       

}