使用SharpMap渲染空间数据

时间:2013-11-05 14:51:15

标签: c# gis sharpmap

我正在尝试使用SharpMap在Windows窗体应用程序中从SQL sever2008R2渲染空间数据。下面是我尝试过的示例代码。每次我尝试运行代码时,我都会收到这个错误消息,我需要分配IGeometryServices或实现IGeometryService,因为SharpMap缺乏全面的文档,如果有可能的话,可以使用示例代码

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 个答案:

答案 0 :(得分:-1)

你试过吗

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();