SWF viewer

From Wildsong
Revision as of 02:54, 29 October 2005 by Brian Wilson (talk | contribs)
Jump to navigationJump to search

What does it take to build a simple SWF (Flash) based vector map viewer?

There are two ways to think about using SWF with a mapserver. The first obvious way (to me) is that the imagemap is generated as a SWF file, meaning that your map itself can be animated. For example, you can support very nice zooom and pan operations.

The second way is to continue to use mapserver to generate static image files in png or jpeg format, and to use SWF in the user interface. That way you can support things like fancy rollover buttons.

In either case, one thing to be aware of is that there is actually a scripting language embedded in Flash called actionscript. Actionscript is just a subset of javascript. So if you are a happy javascript programmer you can also adapt your skills to actionscript. Anyway, pressing on.

For the user interface I suppose you could build the page with Dreamweaver; or you could use the PHP SWF extension or the external Ming library for PHP, and write PHP code to generate the SWF page. So far I am trying the ming approach.

First I built ming as an extension for PHP. Current ming is 0.3beta1 and php is 4.4.0. Support for SWF in PHP means that I can do the fancy user interface things directly from php. Not as posh as Dreamweaver, but coders are like that.

On my TSL 2.2 Linux system, I had to add the bison and libungif-devel rpm packages to get ming to compile. I had to install libungif on the target server.

Once I had the php module installed correctly I created this simple SWF example as a test. (Here is the source code: simple.php source)

Mapserver can generate SWF files directly, if you have compiled it with support for the ming library. So next I rebuilt mapserver with the added command line option to 'configure': --with-ming

Then I revamped my City of Corvallis simple example yet again to generate SWF output instead of png. Or rather, I will do that on Tuesday next week after I figure out why the compile of mapserver dies now! Botheration! Fuss fuss.

Links

PHP reference for ming

I like the simple user interface on this server: http://www.downtownbethesda.com/

Layers turn on and off at different scales, there are basically no controls; just pan and zoom. Pan by dragging, and zoom with slider or scroll wheel.