Viewer for Mapserver-generated Flash Maps
Glenn Brauen
Geomatics and Cartographic Research Centre
Carleton University
June 2004
Overview
This page describes a prototype Flash implementation of a map viewer which is capable of loading the Flash (a.k.a. .swf or SWF for ShockWave Flash) map layers generated by mapserver when the OUTPUTFORMAT is set to SWF with Multiple Layers. The viewer displays the map layers as defined by the mapserver mapfile and shows attributes associated with the map features as the user moves the mouse over the map features.
While I have seen mapserver mailing list discussions concerning how to build a viewer such as this to access the atttribute information encoded in Flash layers by mapserver, I have not seen an example where this has been implemented. The term "Flash Map" can mean either a Flash Application for viewing map images (not necessarily SWF map layers) or it can mean the use of SWF map layers which are probably also viewed from within a Flash application. The examples I have seen on the internet were all the former. I have put this example together to better understand the technology for the latter.
This viewer does not implement pan and zoom features right now. Since Flash is a scalable vector-based file format, there is no reason that these features could not be implemented by the client without need for further updates from the server. Similarly, buttons to hide or display the individual map layers could be implemented on the client.
For more information on mapserver-generated Flash layers, see http://www2.dmsolutions.ca/mapserver/dl/FlashMapserverUserDoc.html
Instructions
The zip file for this demonstration contains:
- ./MultiViewer.swf - Flash viewer application for multi-layer mapserver-generated flash maps. This Flash application requires that the Macromedia Flash plug-in for your browser be installed. This Flash application understands the structure of mapserver-generated Flash map layers and the encoding of attributes within those layers.
- ./MultiViewer.fla - corresponding Flash 2004 MX source for the above. If you have access to Macromedia Flash MX 2004 (i.e., the Macromedia Flash authoring system), then you can browse the source for this Flash application and see how the map layers are loaded and the attributes are accessed.
- ./fmv.html - this page.
- ./fmv.map - mapserver mapfile defining a multi-layer flash map.
- ./fmv_template.html - html template for mapserver map file. Uses MultiViewer.swf to load generated flash map layers.
- ./data/* - data files associated with the above flash map.
- ./tmp/* - this is the temporary directory used to create the Flash map layers. The directory contains one set of map layers generated on my machine using the fmv.map file. If you do not have a SWF-capable mapserver, you can use these map layers to experiment with the viewer application (see below).
To run the demo on a SWF-output-capable mapserver:
- Ensure that your mapserver configuration supports Flash map generation. See http://www2.dmsolutions.ca/mapserver/dl/FlashMapserverUserDoc.html if you are unsure of what's required. I am running mapserver 4.2.0 with Apache 2.0.49, PHP 4.3.6 and Ming 0.2a on a Linux 2.4.22 kernel.
- Extract the contents of the zip file into a directory called "fmv" in your web server's documents directory. In my case this creates the following path to this page: /usr/local/apache2/htdocs/fmv/fmv.html. This page, and in particular, the link below is written assuming that this is your path to the files and you are running your browser on the same machine. If either of those assumptions are incorrect, then you need to edit the link to match your needs (i.e., change the path and/or substitute a host name/address for "localhost").
- Ensure that mapserver has write priveleges to the temporary work directory: ./fmv/tmp.
- Click on the following link to generate and view the flash maps: http://localhost/cgi-bin/mapserv?map=/usr/local/apache2/htdocs/fmv/fmv.map&mode=browse
To experiment with the Flash map layers if you do not have a SWF-output-capable mapserver:
- Extract the contents of the zip file into a directory called "fmv" in your web server's documents directory. In my case this creates the following path to this page: /usr/local/apache2/htdocs/fmv/fmv.html.
- Using the pre-generated Flash map layers in /my_path/fmv/tmp (FMV_1088913753715*), edit fmv_template.html to directly access the mapserver-generated index file for the map layers. This simply requires you to replace the [img] tags in fmv_template.html with "http://localhost/fmv/tmp/FMV_1088913753715.swf". Save the changes to fmv_template.html.
- Load the HTML template file directly into your browser.
Understanding the Demo
The following asociated material may help you understand this demo:
- http://www2.dmsolutions.ca/mapserver/dl/FlashMapserverUserDoc.html.
- Data flow diagram for mapserver generation of Flash map layers. See MS_Dataflow_Flash.pdf.
- If you have access to Macromedia Flash MX 2004, browse the actionscript in MultiViewer.fla.
Comments and questions are welcome. Send email to gbrauen@connect.carleton.ca.
Regards,
Glenn