Vishful thinking…

GeoJSON & GPX support added to the ESRI Silverlight API Contrib

Posted in ArcGIS, ESRI, GIS, Silverlight by viswaug on August 18, 2009

I’ve added support for the GeoJSON and GPX layer types to the ESRI Silverlight API Contrib project on CodePlex. Adding GeoJSON or GPX layer to the ESRI Silverlight API map is real easy and you would add it just like adding a FeatureLayer to the map.

Adding a GeoJSON layer 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:GeoJSONLayer ID="geoJSONLayer"
                     URL="http://localhost/SLMaps.Web/Data/JSON.txt" />
            </esri:Map.Layers>
</esri:Map>

Adding a GPX layer 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:GPXLayer ID="gpxLayer"
                 URL="http://localhost/SLMaps.Web/Data/fells_loop.txt" />
            </esri:Map.Layers>
</esri:Map>

This adds to the GeoRSS layer support already present in the library.

Other than just adding these data sources as layers to the map, The GeoJSONReader & GPXReader classes can also be used to just parse the data source and obtain the geometry and attribute values of the features in the data source if/as required. This should allow for the users to upload GeoJSON & GPX data from their GPS units directly from their computers to the Silverlight map control without the need to upload files to the server. Allowing the workflow to be smoother, faster and simple both on the server-side & client-side.

4 Responses

Subscribe to comments with RSS.

  1. Dave said, on August 18, 2009 at 12:33 pm

    Nice work Vish! This is great… now if I had some Silverlight work in which to use this😉

    Cheers,

    Dave

  2. Bill Dollins said, on October 7, 2009 at 9:59 pm

    Vish,

    This is great! We’ve got a couple of Silverlight projects running right now and GeoJSON was one thing I was looking at. This’ll help a lot.

    Also, thanks for setting up the project on CodePlex.

    Bill

  3. Dan said, on March 22, 2011 at 1:40 pm

    Hi Vish,

    Great Work. Really really useful.

    Has anyone had any luck doing this all programatically though C#? I have been playing with this but i dont seem to see the points drawn on my map. No errors.

    Any advice?

    Cheers
    Dan

    • viswaug said, on March 24, 2011 at 6:42 am

      Hi Dan,

      This works. no issues. The GPX Xaml layer is just a nice-to-have wrapper around the c# classes. CHeck out the code here

      http://esrislcontrib.codeplex.com/SourceControl/changeset/view/72193#965016

      It’s basically just
      _source = GPXReader.ReadGPX( stm );
      Graphics = LoadGraphics(_source);

      private GraphicCollection LoadGraphics( gpxType source )
      {
      GraphicCollection gcs = GPXHelper.LoadGraphics( source );

      foreach( Graphic gr in gcs )
      {
      gr.Symbol = Renderer.GetSymbol( gr );
      }

      return gcs;
      }


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: