Tuesday, February 5, 2008

Building Flex 2 Map Applications

An article I wrote, bit wordy but worth posting ....

Web mapping applications have come a long way over the last few years. The market has split into numerous segments. These include:

  • GIS based applications relying on proprietary products such as those from ESRI, notably arcIMS and arcGIS, and open source alternatives including Mapserver.
  • Sites built around Google maps, Microsofts Virtual Earth and Yahoo Maps.
  • Flash based sites which run in the client using high definition map imagery.
When talking to clients about their mapping needs and tools to satisfy this need we have found much confusion. Is this to be an interactive mapping application or one which provides GIS functionality? More importantly is the difference clearly understood. Google provide a mapping application, ESRI are fundamentally a GIS company. Do clients want the expense and overhead of ESRI products if they only want to display maps (don't get us wrong we love the ESRI product suite)? So purpose, understanding, budget and maintenance are all things to consider. Another is client verses server. We started working with Flash and Flex 2 because we could create nice interfaces, we liked and recognised the power of actionscript and lastly we knew how much we could (potentially) do without needing server calls. The latter, as we will outline, has is own limitations but makes for a remarkably fast application.

Pure GIS

So what is the purpose of the Web site? Are you serving simple interactive web images, or is this a web site whose purpose is to provide spatial analysis. If it is the latter then advanced spatial servers are a requirement. ESRI are the major vendors of GIS software; ArcIMS and ArcGIS, are their two flagships. So buffering, modelling, layer query, data extraction and much more are possible with these products. ArcGIS is a complex beast to install and administer, its also expensive. But it provides extensive GIS functionality out of the box and is highly customisable (through arcObjects). Simple mapping applications are easy and quick to build using .NET (Java is another development option but is poorly supported).
Thoughts and Observations
From our experience most mapping web sites use backend (GIS) servers to simply generate map imagery. Thus a zoom changes the map envelope (extent) and thus requires the regeneration of the map image with the new extent and new resolution. To pay for proprietary software and simply use it for image generation is, in our view, daft. The open source route through Mapserver would be a better way to go (which also offers GIS functionality). But if you are developing a high level GIS applications (and have deep pockets), then the ESRI suite is an excellent option.

Flash Maps

There are a range of excellent mapping sites on the web which use Flash. Flashmaps generate a range of interactive flash based maps commercially. One of the earliest examples we found on the web of a Flash GIS map site was the Davis streetmap. Inspired by this work we at Flexmappers built a Spatial Data Clearinghouse for the US Forest Service (USFS). The success of this application led to other similar USFS projects including the NPSG dynamic map.
Thoughts and Observations
Flash runs on the client in a browser plug in (the flash player). Browser compatibility is not an issue, but users will need the appropriate plug in, or player, to run the Flash application. Developers have the option to bundle all data into the downloaded SWF. Thus the initial application loading is slower, but map interaction then demands no server calls. Flashmaps take this approach for some of their mapping applications. You can also use Flash Remoting to make server calls. Thus the Spatial Data Clearinghouse communicates with ArcIMS (via Java) to provide map interaction and data extraction. So what are the disadvantages? Flash was initially developed as an animation tool. Though Actionscript 2.0 was added and is powerful for application development. Flash remains best for animation development.

Flex 2 Maps

Flex 2 was released in June 2006. Its uptake has been somewhat slow, particularly in the web mapping arena. To their credit ESRI were quick to see the possibilities and launched ArcWEB Services. For the reasons outlines above with regards Flash we were interested in the possibilities Flex 2 offered. Two early prototypes we developed included the Ski Solitude SVG interactive map and a MapServer map viewer. Christophe Coenraets has started working with Flex 2 and Google maps.
Thoughts and Observations
Some of the advantages of Flex 2 include:
  • No cross browser compatibility issues.
  • A rich set of tools to build sophisticated 'desktop like' web applications.
  • Programming done in Actionscript 3; a powerful object oriented language.
  • Client processing, more can be done within the clients Flash player to make sites extremely fast.
To put it simply, we love Flex 2! For Web application development, in our view, it is unrivalled. The creation of sophisticated, great looking, user friendly Web sites has never been easier. For the creative, less technical it is easy to learn and use. For hard core developers, Actionscript 3.0 is incredibly powerful. Used alone or in combination with Javascript/Ajax, PHP etc, the development possibilities are endless. In the online mapping world, where we are focused, we have only just begun to explore the possibilites. Our Ski Solitude application, outlined above, is a client based application, which loads all data on the client side. As a result map interaction almost instantaneous, since it does not reky on server calls to reload the map etc. The Mapserver application uses Flex 2 to build the interface and communicates with PHP for server interaction. We would be happy to share the code for anybody interested. We are looking into advanced GIS functionality using Flex 2 - ArcGIS. Additionally, we are experimenting with adding overlays to maps, allowing users to click georeferenced points to view movies, video, charts etc; Flex 2 is a wonderful multimedia environment.

Modest Maps

The excellent open source Modest maps has both a Flash and Flex 2 api for connecting to and displaying Google Maps, Microsoft Virtual Earth, Yahoo Maps and a number of other interactive map providers. In addition they have a zoomify plug in which enables developers to use 'zoomified' images in a map viewer.
Thoughts and Observations
We are interested to see where this work is going. We have played with modestmaps and have built a test application. Much of the initial work has been done in Flash, slowly things are being ported to Flex 2. When we get chance we plan to dig into the code maybe help with porting and add functionality (hooking into the ArcGIS cache is of great interest). But this work is well worth checking out.

No comments: