Using MapServer (2) – Generating Map Tiles
Wednesday, November 14th, 2007This post is the second in a series on using MapServer. First-time visitors are encouraged to read part 1 which details how to download, setup, and create a web mapping site using MapServer. Additionally, the topic of map tiles has already been introduced in a previous series.
Once the MapServer for Windows (MS4W) package with ka-Map is installed on your local machine, some new mapping functionality becomes available. One area that interests us is the ability to automatically generate a set of map tiles.
ka-Map Configuration
The first step in creating a set of map tiles is to configure ka-Map to point to a valid MapServer mapfile (see here for more on a mapfile). Navigate to this directory: C:\ms4w\apps\ka-map-1.0\include and open the file named config.php in any text editor.
This configuration file contains several parameters which you should be familiar with before creating our map tiles. We won’t change any of their values yet but it is important to understand what they do. First, on lines 73 and 74, the pixel size of each tile to be generated is defined:
$tileWidth = 256; $tileHeight = 256;
Lines 106 through 110 define the most important parameters:
$aszGMap = array ( 'title' => 'GMap 75', 'path' => '../../gmap/htdocs/gmap75.map', 'scales' => array( 40000000, 25000000, 12000000, 7500000, 3000000, 1000000 ), 'format' =>'PNG' );


