[ka-Map-users] "Starting kamap with different maps"

Steve Walker walker at mfgis.com
Mon Mar 9 12:24:12 EST 2009


In January of 2007 I posted a discussion of my modifications which may in
part meet your needs:

Excertps from my post:

I would like to share here a strategy I have been pursuing which allows me
to configure Ka-Map! (in part) from the web page level (or more precisely,
from the web pages' file system path level).

The motivation was my desire to create a separate web page for multiple
cities,  states, countries, etc., and to specify important Ka-Map!
parameters (namely the map name and map extent) associated with these
pages from the same file system path as the web page itself.

I have been able to achieve this by making changes to init.php and to
config.php (as spelled out below) as well as introducing new files named
variables.php and load_mapfile.php

Variables.php (Miami)
// also, what ever else I want index.phtml to read - $cityName='Miami' etc.

Variables.php (Springfield)
// also, what ever else I want - $cityName='Springfild' etc.

Now that I have set up the variables.php files, I wish to modify init.php
to access them.  (I have ka-map-1.0.b1-20060817 installed)

So, right at the very top of init.php I want to include my variables.php <?
include_once(variables.php);  // should be modified to test for existence

The first thing this has done is to have set the mapscript szMap variable
and thus chosen my map before config.php is ever read (more about
config.php modifications below).  The second thing it has done assigned
the desired map extent to a variable which I then use to over-ride the
values set in the Mapserver map file (after all, the map extent of Florida
exceeds that of Miami, and I want to show Miami)

include/config.php is read.   Here is how I have implemented that:

Essentially, I modify config.php to test whether szMap is already set, and
if so to use that value rather than the one specified in config.php.   In
other words, I have taken the map choice away from config.php and placed
it at the level of the web page, where (to me) it more appropriately

In config.php, after the parameters are set and before the first map is
identified (around line 105) I include the following code:

// if the map name is set see if we can quick load it but if not we'll
want //to use the standard approach, below
if (!isset($szMap)) { $szMap='DEFAULTMAP'; }

if (file_exists($my_szMapFile)) { include('load_mapfile.php'); }

// if the aszMapFiles variable has been set we can skip the parameters  //
below. but if not, proceed as per the standard approach

What I have done here is introduce a new folder include/mapfiles and a new
script load_mapfile.php

This does two things,  first, it finds and loads my map file, and it
allows me to create and place as many map files as I wish without having
to edit config.php for each new map, thus avoiding the possibility of
wrecking the config.php with each edit.

Each entry in mapfiles is simply a text file with four lines representing
the contents of the array variables which previously had to be hard-wired
into the code of config.php, such as:


These are read into the same structure as the original config.php through
the use of my new load_mapfile.php script, which looks like this:

//Read a text file containing ka-map required map parameters in lieu //of
specifying them within config.php
//$szMap and $my_szMapFile validated by default before calling
$lines = file($my_szMapFile);

$thisArray = array(
   'title' => $thisTitle,
   'path'   => $thisPath,
   'scales' => $thisScales,
   'format' => $thisFormat);
// Note that my array is really just a single map, so I have broken the
// chance to change maps from within the web page.
$aszMapFiles = array ( $szMap => $thisArray);

?>   // end load_mapfile.php

This is working fine with 50000+ web pages

I attempted to document the process in as much detail in the posting I
identified above and repeated here:


But please let me know if you have any questions.


>> 1. Is it possible to create a link between an mapfile-layer and an
>> MySQL-Database. I'd like to get it reacting as an mouseclick event in
>> kamap
>> for more information opening a window with this information from the
>> database. Do you have any idea how this could work?
> it is possible.
> I did it for some clients.
> you need to alter the map_query_float.php file and create a page tha
> dynamically get infos from MySQL.
> you naturally need to create a link between your shp and your DB.
> Think about doing a definitive solution using Postgresql/postgis.
>> 2. Is it possible to get kamap starting with different maps. I
>> considered
>> something like an variable that is transferred with the URL and tells
>> kamap
>> with which map it should start instead of getting this out of the
>> config.php
>>  Does anybody already realised this idea or can give me a hint / keyword
>> what to do?
> it's already supported, if I've undestood what you mean.
> is this link what you are looking for?
> http://www.ominiverdi.org/ka-map/ka-map/htdocs/?map=europe
> ciao
> lorenzo
>> Thanks very much for your help!
>> Regine
>> _______________________________________________
>> ka-Map-users mailing list
>> ka-Map-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/ka-map-users
> ------------------------------
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
> End of ka-Map-users Digest, Vol 47, Issue 5
> *******************************************

Steve Walker
Middle Fork Geographic Information Services
walker at mfgis.com

More information about the ka-Map-users mailing list