Tuesday, March 24, 2009

Flex Spatial Flickr

Some of you may be aware that the ArcGIS API for Microsoft Silverlight/WPF is now available as a public Beta. This was released on the eve of the 2009 ESRI Developer Summit. I am among the many who unfortunately couldn't attend this year due to the current economic climate.

The Silverlight API looks rather promising - very similar in form and function to the Flex API. The ArcGIS Server Development Team provided this Spatial Flickr sample in the Code Gallery. This is a pretty slick mashup for sure.

As an advocate of Flex, this sample inspired me to develop a similar sample using the Flex API. Here is the live application as well as the application source.

This sample uses the ActionScript 3.0 API for Flickr available on Google Code. This photo search method of this API was missing needed 'geo' functionality -- so I extended it accordingly.

This sample application will retrieve Flickr photos for the current map extent. Photo tags are optional, but will be included in the search if provided. The search results are added to the map as well as provided in a data panel. The map graphics and data panel respond to mouse focus and click events. My sample doesn't have all the animation provided in the Silverlight sample -- althought it could be extended to include such. There are a few noteable quirks with the map graphics particularly those near the edges of the map window. Perhaps I shall revisit this sometime.

So, Silverlight or Flex? Time will certainly tell...

Saturday, March 21, 2009

Easy MVC Pattern for ESRI Flex API

I've gotten off to kind of a slow start here with my blogging. It seems this space will in fact be more of a dribble than a torrent.

In the year that I have been developing with the ESRI Flex API I have come to learn the importance and value of using a good architectural design pattern. I am a big fan of the Model-View-Controller (MVC) pattern and use it in most if not all of my projects. Using the pattern has saved my ass on numerous occassions -- and neglecting to use it has come back to bite me.

Although there are a number of popular Flex MVC frameworks available (eg. Cairngorm, pureMVC, mate, Model-Glue, among others) --these can be overkill for simple web mapping applications -- particularly for beginners. Ive found that many folks have chosen to avoid these what can be larger more complicated frameworks in favor of their own home-grown MVC solutions. I believe that can be a good option -- particularly for smaller projects.

Once such pattern is the EasyMVC pattern by Tom Bray. Be sure to check out the recorded seminar for all the details. This is the MVC pattern that I use most frequently. In this post I have provided the ESRI Flex API MapSwitcher sample using this pattern.

Here is the application in action as well as the application source.

I am certainly not advocating this as the best MVC pattern out there... but I believe its a good place to start place for beginners and small projects. In future posts I will likely use either this pattern -- or the pattern used by the ESRI Sample Flex Viewer (for posts in that context).

In the meantime, happy Flexing and welcome to MVC.