HOW TO DRAW ICONS OR IMAGES ON A MAPSERVER GENERATED MAP
(c)2005 by Roberto Colonello - Parsec Tech srl

 

Explanation: the main program

First include the mapscript library (if necessary)
dl("php_mapscript.so"); for linux or dl("php_mapscript.dll"); for windows

define("img_WIDTH", 0);
define("img_HEIGHT", 1);
define("img_TYPE", 2);
Define constants for the array we have as result from the function GetImageSize.

$MyHost = "localhost";
$MyLogin = "weatherlogin";
$MyPassword = "ax18892";
$MyDatabase = "mapexample";
Defined the variables for the access to the mysql database.

$mappath = "/tmp";
$scale_to_showicons = 1000000;
The images generated by mapserver have to be into a directory visible by the webserver, but only part of this path will be really visible with a browser.
For example the images generated with the map file in this example are stored into "/tmp/ms_tmp" but will be visible by browser with "/ms_tmp".
To know where the images are stored, the script has to append to the url of the image the basic path (mappath).
scale_to_showicons is a scale from which I want to show the icons. If the map is interactive, I want to show the icons only if the scale is less than this scale.

$map = ms_newMapObj("itasca.map");
Creates a map object and with the itasca map

$img = $map->draw();
Draws the map


$url = $img->saveWebImage();
Saves the image with the map and get the url of the image

AddImagesToMap($url);
Calls the function that puts the icons on the map

 

<--- The PHPMapcript code
(C)2005 Roberto Colonello
Parsec Tech srl
39012 - Merano (BZ) - ITALY
roberto@parsec.it