Preparing ka-Map

From Ka-Map Wiki

Jump to: navigation, search

much of the text of this page is from Tyler Mitchell article Build AJAX-Based Web Maps Using ka-Map .

Contents

[edit] Requirements

Installing ka-Map is easy provided you already have the following already running together:

  • Apache (web server)
  • Mapserver
  • PHP
  • Mapscript

I hear these can be a bit difficult to configure separately, so if you want to install a standalone suite containing all of these simply install FGS (Linux) or ms4w (Windows).

[edit] Easy ways to install ka-Map prerequisites

ms4w is available here: http://www.maptools.org/dl/ms4w/ka-map-ms4w-1.0.zip

For help installing FGS check out: Installing Apache/Mapserver/PHP/Mapscript on linux (installing FGS)


[edit] 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.

As a source package from the ka-Map section of MapTools in the form of:

  • 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).

In order to download the CVS version you will need a CVS client. On Linux machines you can download the CVS version by using the following command:

cvs -d (server_path) checkout (local_folder_name)

In the above command (server_path) should be replaced by the server path in [1] and (local_folder_name) by the name of the folder on the local machine where the files will be downloaded to.


The files are stored in a very simple folder structure:

.../kamap-1.0/
.../kamap-1.0/docs/
.../kamap-1.0/htdocs/
.../kamap-1.0/htdocs/images/
.../kamap-1.0/include/

.../kamap-1.0/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.


[edit] Security Warning

In a production or public environment it is not a good practice to put your global.map file in a publicly accessible location. This example is meant only for internal testing and to keep folder management to a minimum for getting started. Because global.map is in the htdocs folder it can be accessed through a web URL. This is a particularly bad idea if you are connecting to databases in your map file where database user names may be explicitly set.

This commonly used folder structure keeps the htdocs folder separate from the map file and data:

.../kamap-1.0/map/global.map
.../kamap-1.0/data/countries_simpl.*
.../kamap-1.0/data/day_clouds.*

[edit] Web Server Aliases

To allow your web server to use ka-Map, you need to set some web server aliases. With FGS and MS4W this may be done for you automatically. Otherwise, you will need to add something like this to your web server configuration, for example in an Apache httpd.conf file:

Alias /ka-map/ "/opt/fgs/apps/kmap-0.1.1/htdocs/"
<Directory "/opt/fgs/apps/kmap-0.1.1/htdocs/">
       Options Indexes
       AllowOverride None
       Order allow,deny
       Allow from all
</Directory>

This allows you to enter a simple URL (/ka-map/) and have it point to the file path where ka-Map content is stored.

[edit] ka-Map Configuration Files

ka-Map comes with one main configuration file:

.../ka-map/include/config.dist.php

that should be renamed in

  .../ka-map/include/config.php

Once the handful of settings in this file are set, you will have a fully functioning ka-Map application. For FGS and MS4W packages, many of these settings are already taken care of. There is documentation throughout config.php to guide you through each setting. There are only three different types of settings that you really need to worry about.

[edit] Setting Up Library Pointers

ka-Map requires both PHP MapScript and the GD module for PHP. config.php needs to point to these library files (around line 23):

$szPHPMapScriptModule = 'php_mapscript_cvs_rel.4.6.0.beta2.'.PHP_SHLIB_SUFFIX;
$szPHPGDModule = 'php_gd.'.PHP_SHLIB_SUFFIX;

The first one points to the file name prefix for the PHP MapScript library. This looks somewhat verbose, because the above example uses a very recent beta version of PHP MapScript. You change this to match the filename for the php_mapscript library that is on your system. In many cases this looks as simple as:

$szPHPMapScriptModule = 'php_mapscript.'.PHP_SHLIB_SUFFIX;

Or:

$szPHPMapScriptModule = 'php_mapscript_46.'.PHP_SHLIB_SUFFIX;

The documentation says that the pointer to php_gd will likely need to be changed to php_gd2, if running on Windows.

Note that the PHP_SHLIB_SUFFIX variable will automatically add the filename suffix. For example, .so or .dll, depending on your operating system. Don't include the suffix in this filename setting.

[edit] Adding Your Map File

To have your custom application show up in ka-Map, you need to tell ka-Map where your mapfile is, as well as some other map-specific settings. Around line 80 you'll find the settings for the $aszMapFiles array. It will already be set to use a mapping application called GMap, but you can change it to match this one:

$aszMapFiles = array(
       "weather"     => array( "Global Weather",
                               "/opt/fgs/apps/kamap-0.1.1/htdocs/global.map",
                               array( 100000000, 50000000, 15000000 ),
                               "PNG")
);

This sets up an array of information, all stored within the $aszMapFiles variable. The first setting is the name of the ka-Map instance you are configuring; in this case the application is called "weather" and uses the global.map file you created earlier. This name is used in other places, as you will see later on.

The second setting is the text, "Global Weather", which is the name that will appear in the drop-down box on the web page. From this drop-down you can choose which map file you want to use.

The third setting points to the location of the global.map file. Depending on how your system is configured, this will vary. In this example, global.map was stored in the ka-Map htdocs folder, alongside the data folder.

[edit] Setting Map Scales and Image Formats

The fourth setting is a list of scales. These are the map scales that the user will be allowed to view the map at. For example, 1,000 would be the map scale as a representative fraction of 1:1,000. This means that one inch on screen represents one thousand inches on the ground.

The final setting is the output image format to be used, in this case "PNG".

Note that there are two closing parentheses, one after "PNG", which ends the settings for the "weather" array. If you want to add more than one instance to ka-Map, put a comma after this parenthesis and create a whole new instance key.

The second closing parenthesis is on a separate line and followed by a semicolon. It ends the settings for the $aszMapFiles array.

With those changes made to config.php, you are ready to test your map.

Personal tools