锐图类型转换 - WPF
本文关键字:WPF 类型转换 | 更新日期: 2023-09-27 18:30:56
我想在SharpMap框中显示一个.shp
的shapefile,我写了这段代码:
它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。数据来源,就像克莱门斯说:
SharpMap.Layers.VectorLayer vlay = new SharpMap.Layers.VectorLayer("States");
string path = @"D:'Studies'file.shp";
vlay.DataSource = new SharpMap.Data.Providers.ShapeFile(path);
MapBox.Map.Layers.Add(vlay);
MapBox.Map.ZoomToExtents();
MapBox.Refresh();