Pergunta

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 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);
    }
}
Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top