【发布时间】:2016-01-18 05:58:32
【问题描述】:
我想在 SharpMap 框中显示一个 shapefile .shp,我写了这段代码:
public partial class Details : UserControl { public Details() { InitializeComponent(); SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States"); string path = @"D:\Studies\file.shp"; SharpMap.Map myMap = new SharpMap.Map(new System.Drawing.Size(500, 250)); vlay=new SharpMap.Data.Providers.ShapeFile(path); MapBox.Map.Layers.Add(vlay); MapBox.Map.ZoomToExtents(); } }
它没有运行,它显示:
SharpMap.Data.Providers.ShapeFile可以转换成SharpMap.Layers.VectorLayer
我该怎么办?
【问题讨论】:
-
试试
vlay.Datasource = new SharpMap.Data.Providers.ShapeFile(path);而不是vlay = new SharpMap.Data.Providers.ShapeFile(path);。 -
谢谢,成功了:)
标签: c# wpf visual-studio sharpmap