This project has moved and is read-only. For the latest updates, please go here.

v2 DemoWinForm compile problem

Topics: SharpMap Project, SharpMap v2.0
Jul 6, 2008 at 7:43 PM
Hi, I downloaded v2 and SharpMap compiled with no errors, however the DemoWinForm project gave the following 2 errors:

Error    1    The type or namespace name 'VectorStyle' could not be found (are you missing a using directive or an assembly reference?)    D:\SharpMap\SharpMap_v2.0_2008-06-20_Drop\SharpMap\Demos\DesktopClient\RandomFeatureLayerFactory.cs    24    20    DemoWinForm
Error    2    The type or namespace name 'VectorStyle' could not be found (are you missing a using directive or an assembly reference?)    D:\SharpMap\SharpMap_v2.0_2008-06-20_Drop\SharpMap\Demos\DesktopClient\RandomFeatureLayerFactory.cs    143    24    DemoWinForm

I have investigated and VectorStyle is not defined within the Styles folder in the SharpMap project. Can someone explain how to clear this problem.

Many thanks
Derek

Jul 6, 2008 at 8:55 PM
Hi Derek, demowinform is not part of the solution currently hth jd
Jan 2, 2015 at 2:10 PM
I believe this problem is valid to the basic tutorial available today too (https://sharpmap.codeplex.com/wikipage?title=Tutorial%20-%20Example%202%3a%20Styling%20the%20layer%20with%20UniqueValueRenderer&referringTitle=SharpMap%20Tutorial). In Example 2, "VectorStyle" should be replaced by "SharpMap.Styles.VectorStyle" and "IStyle" by "SharpMap.Styles.IStyle". The correct code follow below:

SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
        vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("D:\\teste\\states_ugl\\states_ugl.shp", true);

        //Create the style for Land
        SharpMap.Styles.VectorStyle landStyle = new SharpMap.Styles.VectorStyle();
        landStyle.Fill = new SolidBrush(Color.FromArgb(232, 232, 232));

        //Create the style for Water
        SharpMap.Styles.VectorStyle waterStyle = new SharpMap.Styles.VectorStyle();
        waterStyle.Fill = new SolidBrush(Color.FromArgb(198, 198, 255));

        //Create the map
        Dictionary<string, SharpMap.Styles.IStyle> styles = new Dictionary<string, SharpMap.Styles.IStyle>();
        styles.Add("land", landStyle);
        styles.Add("water", waterStyle);

        //Assign the theme
        vlay.Theme = new SharpMap.Rendering.Thematics.UniqueValuesTheme<string>("class", styles, landStyle);

        mapBox1.Map.Layers.Add(vlay);
        mapBox1.Map.ZoomToExtents();
        mapBox1.Refresh();
        mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
Jan 8, 2015 at 8:41 AM
Thanks for pointing that out, I updated the tutorials.