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:

To run the demo on a SWF-output-capable mapserver:

  1. 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.
  2. 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").
  3. Ensure that mapserver has write priveleges to the temporary work directory: ./fmv/tmp.
  4. 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:

  1. 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. 
  2. 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.
  3. Load the HTML template file directly into your browser.

Understanding the Demo

The following asociated material may help you understand this demo:

  1. http://www2.dmsolutions.ca/mapserver/dl/FlashMapserverUserDoc.html.
  2. Data flow diagram for mapserver generation of Flash map layers. See MS_Dataflow_Flash.pdf.
  3. 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