Build AJAX-Based Web Maps Using ka-Map
by Tyler Mitchell
|
Pages: 1, 2, 3, 4, 5, 6
MapServer Configuration
Next, you need to create a MapServer application configuration file. This is
a simple text file that tells MapServer how to access data and draw the map.
This file is commonly called a mapfile. It contains several sections
called objects. They start with a keyword for the object type and close with
the END keyword.
Here is a basic map file using the two data layers mentioned above:
MAP
NAME global_map
STATUS ON
SIZE 600 300
EXTENT -180 -90 180 90
UNITS DD
IMAGECOLOR 255 255 255
IMAGETYPE png
WEB
IMAGEPATH "/opt/fgs/apps/kamap-0.1.1/htdocs/tmp/"
IMAGEURL "/ka-map/tmp/"
END
LEGEND
TRANSPARENT TRUE
END
SCALEBAR
TRANSPARENT TRUE
END
LAYER
NAME clouds
TYPE RASTER
STATUS ON
DATA "data/day_clouds.tif"
END
LAYER
NAME countries
TYPE LINE
STATUS ON
DATA "data/countries_simpl.shp"
CLASS
NAME "Country Boundaries"
STYLE
COLOR 200 100 100
END
END
END
END
Save the above into a simple text file named global.map.
Testing the Map File
Incorrect settings in your map file will cause problems. Before trying to use a map file with ka-Map, you should test it.
Depending on how you have MapServer installed, you may have a program called shp2img.
This command-line tool uses the map file to create an image file. You run it
like:
> shp2img -m global.map -o test.png
If all goes well, there should be a test.png image file containing
a map. If the program fails or gives errors, then you have a problem with your
map file.
Further testing may be required to fully guarantee that the map file is working, but this test is a good first cut. To make sure that the maps created from the map file are going to be readily accessible to a web server, you should also test it in a web environment. This is discussed further in the "Further Adventures" section below.
Preparing ka-Map
If you were building a traditional MapServer web map, the next step would be to create some HTML form pages and process it with the MapServer CGI executable. With ka-Map, you can get started out-of-the-box with minimal configuration. First, you need to have ka-Map's configuration files and PHP scripts.
ka-Map comes in three different packages.
- A g'zipped tar ball archive
- A zip format archive
- An online CVS repository
-
As a module for the FGS Linux Installer, grab it by using the command:
fgs install kamap-base:0.1.1 http://dl.maptools.org/dl/fgs/modules/
-
As a zip package for MapServer For Windows (MS4W).
The ka-Map 0.1.1 distribution is comprised of about 38 files:
-
Two JavaScript scripts
-
Two text files
-
Two HTML files
-
Eight PHP scripts
-
24 GIF/JPEG/PNG images
You may have more files than this if you acquired a different version of ka-Map.
The files are stored in a very simple folder structure:
.../kamap-0.1.1/
.../kamap-0.1.1/htdocs/
.../kamap-0.1.1/htdocs/images/
You then create another folder for storing map-image tiles generated by ka-Map:
.../kamap-0.1.1/htdocs/tmp/
All the files you are going to deal with are in the htdocs folder.
To keep things really simple, move the map file and data folder here as well.
Your structure should look like:
.../kamap-0.1.1/htdocs/global.map
.../kamap-0.1.1/htdocs/data/countries_simpl.*
.../kamap-0.1.1/htdocs/data/day_clouds.*