开发者

Displaying ShapeFiles in Silverlight ESRI Map

开发者 https://www.devze.com 2023-01-29 07:54 出处:网络
Here is my situation, I have an ESRI Map Silverlight application that needs to display ShapeFiles that were given to me the client.

Here is my situation,

I have an ESRI Map Silverlight application that needs to display ShapeFiles that were given to me the client.

The only third party library I've found that will allow you to do this is the ESRI Silverlight API Contrib. The example they give is to use an Open File Dialog to select the shape files and to load them into a FileInfo classes to show. (See example on site's frontpage).

However I run into the issue that since it is a Silverlight app, any attempt to instantiate an instance of a FileInfo object causes the app to crash.

So my question is, is there a way for me to load/display shape files that I have saved locally to the app in Silverlight?

Please let me know if you need me to give more info.

Thanks in advance!

Code:

FileInfo runwayShp = new FileInfo("Layers\\Runway.shp"); //This l开发者_JAVA百科ine 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);
    }
}


I have a silveright app that is doing pretty much the same thing, but what I am doing is uploading the shapefile as a blob to a SQL db on the back end, and then grabbing it from there.

for what you are trying to do, you should look at this codeplex project. I think it will help you out.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号