Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

How to Add Shapefile to map in ArcGIS Silverlight application runtime ?

I published the shapefile feature as map service on arcgis server and consumed it my SL Application through the service Url but the shapefile feature does not added to the map ..

what's wrong?

share|improve this question
1  
Welcome to SE.GIS forum. Did you search this on web ? If possible please share your code. –  Sunil Jun 6 '13 at 8:23
add comment

1 Answer

What version do you have ? 10 ? 10.1 ? You can use : http://esrislcontrib.codeplex.com

Example C#:

private void openFileDialog_Click( object sender, RoutedEventArgs e )
        {
            //Create the dialog allowing the user to select the "*.shp" and the "*.dbf" files
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Multiselect = true;

            if( !( ofd.ShowDialog() ?? false ) )
                return;

            //Get the file info objects for the SHP and the DBF file selected by the user
            FileInfo shapeFile = null;
            FileInfo dbfFile = null;
            foreach( FileInfo fi in ofd.Files )
            {
                if( fi.Extension.ToLower() == ".shp" )
                {
                    shapeFile = fi;
                }
                if( fi.Extension.ToLower() == ".dbf" )
                {
                    dbfFile = fi;
                }
            }

            //Read the SHP and DBF files into the ShapeFileReader
            ShapeFile shapeFileReader = new ShapeFile();
            if( shapeFile != null && dbfFile != null )
            {
                shapeFileReader.Read( shapeFile, dbfFile );
            }
            else
            {
                HtmlPage.Window.Alert( "Please select a SP and a DBF file to proceed." );
                return;
            }

            //Add the shapes from the shapefile into a graphics layer named "shapefileGraphicsLayer"
            //the greaphics layer should be present in the XAML or created earlier
            GraphicsLayer graphicsLayer = MyMap.Layers[ "shapefileGraphicsLayer" ] as GraphicsLayer;
            foreach( ShapeFileRecord record in shapeFileReader.Records )
            {
                Graphic graphic = record.ToGraphic();
                if( graphic != null )
                    graphicsLayer.Graphics.Add( graphic );
            }
        }
share|improve this answer
    
10.1 But What's The NameSpace for ShapeFile Class ? Thank You –  Nermin Jun 14 '13 at 22:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.