Vishful thinking…

Flashing a graphic in the ESRI Silverlight API

Posted in ESRI, Silverlight by viswaug on May 28, 2009

Being able to flash a shape on the map is a nice usability feature in GIS applications to relate shapes on the map to attributes in a data table or data grid. Also, most GIS users have gotten used to the feature in ArcMAP. I had written up an extension method to the Graphic class in the ESRI Silverlight API to be able to do this easily with a simple function call. Here is the code for the extension method.

        public static void Flash( this Graphic graphic )


            Flash( graphic, 200, 10 );



        public static void Flash( this Graphic graphic, double milliseconds, int repeat )


            int count = 1;

            repeat = repeat * 2;

            Symbol tempSymbol = graphic.Symbol;

            Storyboard storyboard = new Storyboard();

            storyboard.Duration = TimeSpan.FromMilliseconds( milliseconds );

            graphic.Symbol = null;

            storyboard.Completed += ( sender, e ) =>


                if( count % 2 == 1 )

                    graphic.Symbol = tempSymbol;


                    graphic.Symbol = null;


                if( count <= repeat )








After including the above extension method in your project just call the ‘Flash’ method on the graphic object


Note that I am using the Storyboard as the timer which is preferred over of the DispatcherTimer.

This has also been added to the ESRI Silverlight API Contrib project here.


ESRI SL API Contrib – Point in polygon & buffer point for the WGS84 spatial reference system

Posted in Uncategorized by viswaug on May 27, 2009

I just added some utility methods to the ESRI Silverlight API Contrib project that do the following

  1. Determine if a point is inside a polygon. Find the code here
  2. Buffer a point in the WGS84 spatial reference system. Find the code here
  3. Midpoint of two points in the WGS84 spatial reference system. Find the code here
  4. Find the end point given an origin point with a distance and an angle. Find the code here

The above methods should help you avoid some HTTP requests back to the ArcGIS Server to perform these spatial operations. Thus reducing the load on your ArcGIS Server and also increasing the performance of your web application by sticking to Steve Souders’s performance rule number one even though this is a Silverlight client.

Loading Shapefiles into the ESRI Silverlight map without uploading to the server

Posted in Uncategorized by viswaug on May 24, 2009

I have been working with Silverlight and in particular the ESRI Silverlight API recently and have been having a lot of fun with it. It is a refreshing change from working with the HTML/CSS/JS combo, even though I do miss the the simplicity and power of HTML/CSS/JS a lot of times. Silverlight brings with it a lot of capabilities that wasn’t possible with JavaScript. These capabilities in Silverlight can help simplify some of the workflows and increase the usability of some of the features needed in a lot of the web-based mapping applications. Like for example, one of the common requirements is for users to be able to view Shapefiles on their machines on the web maps.

With the JavaScript APIs, the only way this could be achieved was to upload the Shapefiles to the web server and then render the shapefiles either as images on the server that are sent down to the browser or as SVG/VML in the browser. Well, this is where the power of Silverlight helps us simplify things by allowing us to open and read the shapefiles in the Silverlight plug-in of the browser itself. This eliminates the need for uploading the shapefiles to the server and thus simplify the workflow involved.

There are a lot more things that the Silverlight plug-in is capable of that a lot of web-mapping applications can use. The ESRI Silverlight API packs a lot of punch but there are still a lot more holes to be filled. So, to help fill those holes, I have started an open-source project on CodePlex where I have uploaded some of the useful things that I have been working on. Please find the link to the project below.

ESRI Silverlight API Contrib

The project 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


Please download and use the project as you see fit. Even better, you can sign-up as a contributor and help grow the project and the codebase. I also welcome any and all inputs on other ideas for new features that you might want to see added or critiques of the current codebase.