1

这是我的情况,

我有一个 ESRI Map Silverlight 应用程序,它需要显示客户端提供给我的 ShapeFiles。

我发现的唯一允许您执行此操作的第三方库是ESRI Silverlight API Contrib。他们给出的示例是使用打开文件对话框来选择形状文件并将它们加载到 FileInfo 类中以显示。(参见网站首页上的示例)。

但是我遇到了一个问题,因为它是一个 Silverlight 应用程序,任何实例化 FileInfo 对象实例的尝试都会导致应用程序崩溃。

所以我的问题是,有没有办法让我加载/显示我在 Silverlight 中本地保存到应用程序的形状文件?

如果您需要我提供更多信息,请告诉我。

提前致谢!

代码:

FileInfo runwayShp = new FileInfo("Layers\\Runway.shp"); //This line breaks, says file access is denied.
FileInfo runwayDbf = new FileInfo("Layers\\Runway.dbf");
ShapeFile shapeFileReader = new ShapeFile();
if (runwayShp != null && runwayDbf != null)
{
    shapeFileReader.Read(runwayShp, runwayDbf);
}
GraphicsLayer graphicsLayer = MyMap.Layers["ShapeLayer"] as GraphicsLayer;
foreach (ShapeFileRecord record in shapeFileReader.Records)
{

    Graphic graphic = record.ToGraphic();
    if (graphic != null)
        graphicsLayer.Graphics.Add(graphic);
    }
}
4

1 回答 1

0

我有一个silveright应用程序,它在做几乎相同的事情,但我正在做的是将shapefile作为blob上传到后端的SQL db,然后从那里抓取它。

对于你想要做的事情,你应该看看这个 codeplex 项目。我想它会帮助你。

于 2011-02-01T22:53:00.730 回答