Using SharpMap to render spatial data

1.8k Views Asked by At

I am trying to use SharpMap to render spatial data from SQL sever2008R2 in a windows form application. Below is a sample code I tried out. Everytime I tried running the code I keep getting this error message that I need to assign IGeometryServices or implement IGeometryService, since SharpMap lacks comprehensive documentation, can any on point me in the right direction please, if possible with a sample code

SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
        //vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("d:\\+PMF\\GIS\\states_ugl.shp", true);

        SharpMap.Data.Providers.SqlServer2008 d = new SharpMap.Data.Providers.SqlServer2008(connectionString, "view1","geom","ID",SharpMap.Data.Providers.SqlServerSpatialObjectType.Geometry,false  ,4326  );
 mapBox1.Map.Layers.Add(vlay);
        mapBox1.Map.ZoomToExtents();
       // mapBox1.Map.BackColor = Color.BlueViolet;
        mapBox1.Refresh();
1

There are 1 best solutions below

0
On

Did you try

SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
//vlay.DataSource = new SharpMap.Data.Providers.ShapeFile("d:\\+PMF\\GIS\\states_ugl.shp", true);

SharpMap.Data.Providers.SqlServer2008 d = new SharpMap.Data.Providers.SqlServer2008(connectionString, "view1","geom","ID",SharpMap.Data.Providers.SqlServerSpatialObjectType.Geometry,false  ,4326  );
vlay.DataSource = d;
mapBox1.Map.Layers.Add(vlay);
mapBox1.Map.ZoomToExtents();
// mapBox1.Map.BackColor = Color.BlueViolet;
mapBox1.Refresh();