This project is read-only.
This library is meant to be complimentary to the ESRI Silverlight API. It currently contains the following features

1) A custom GeoRSS layer type that can be added to the ESRI Silverlight API map

2) An custom map layer where the image is created dynamically in the browser itself. The current layer regenerates the image for the layer multiples times a second to simulate ripples on the map.

3) Utility classes that will help users load shapefiles from their computer directly on to the Silverlight API map without uploading the shapefile to the server

4) A custom GeoJSON layer type that can be added to the ESRI Silverlight API map

5) A custom GPX layer type that can be added to the ESRI Silverlight API map

To build the library, you MUST agree to the ESRI Silverlight API terms and copy the ESRI Silverlight API DLLs into the "\lib\ESRI\Silverlight\" folder.
The ESRI Silverlight API is available at http://resources.esri.com/arcgisserver/apis/silverlight/

To use the library in your Silverlight page add a namespace reference to it in your XAML page like below

<UserControl x:Class="SLMaps.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="clr-namespace:ESRI.ArcGIS;assembly=ESRI.ArcGIS"
xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:esriWidgets="clr-namespace:ESRI.ArcGIS.Widgets;assembly=ESRI.ArcGIS.Widgets"
xmlns:slContrib="clr-namespace:Vishcious.ArcGIS.slcontrib;assembly=Vishcious.ArcGIS.slcontrib">


Here is how to add a GeoRSS layer to your map.

<esri:Map x:Name="MyMap" Grid.Row="1">
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"/>
                <slContrib:GeoRSSLayer URL="http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M5.xml"/>
            </esri:Map.Layers>
</esri:Map>


Here is how to add the rain drop layer that is dynamically generated on the client-side to the map

<esri:Map x:Name="MyMap" Grid.Row="1">
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"  
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"/>
                <slContrib:RainDropLayer />
            </esri:Map.Layers>
</esri:Map>


Here is how you can allow the users to upload shapefiles from their computer to the Silverlight map

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 );
            }
        }


Here is how to add a GeoJSON layer to your map.

<esri:Map x:Name="MyMap" Grid.Row="1">
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"/>
                <slContrib:GeoJSONLayer ID="geoJSONLayer" URL="http://localhost/SLMaps.Web/Data/JSON.txt" />
            </esri:Map.Layers>
</esri:Map>


Here is how to add a GPX layer to your map.

<esri:Map x:Name="MyMap" Grid.Row="1">
            <esri:Map.Layers>
                <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" 
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"/>
                <slContrib:GPXLayer ID="gpxLayer" URL="http://localhost/SLMaps.Web/Data/fells_loop.txt" />
            </esri:Map.Layers>
</esri:Map>

Last edited Aug 18, 2009 at 2:25 AM by viswaug, version 15