Dynamic Maptitle
Stefanie Weykam
sweykam at TELELINE.ES
Tue Jul 26 07:33:41 PDT 2005
Gerjan,
Here comes an extract of my function. I took the database query part and some other conditions out, so things get hopefully clearer.
I don't remember why I had to create a line object, but it works. Don't forget to draw the map after you modified the layer.
You can see how it works here:
http://www.vertebradosibericos.org/aves/atlas/presentacion.html
(click on 'mapas de distribución...')
good luck!
Stefanie
###### change the map title #######
# not shown here:
# establish conection to the database to get the new parameter for the title
# query result returns an array; $arrayVal[0] is the scientific name of the
# species I am looking for (is 'year' for you)
# $specname=$arrayVal[0]
# get layer parameters from map file
$subtitESP=$map->getLayerByName('subtitESP');
# create class object using the existing class parameters
$oClass=$subtitESP->getClass(0);
# ..and set label font and size (only if you wish to change them)
$oClass->label->set('font', 'verdana-italic');
# create a point and a line object (line object will have only one point here)
$oP=ms_newPointObj();
$oL=ms_newLineObj();
# create shape object
$shape=ms_newShapeObj(MS_SHAPE_POINT);
# set coords of the point and add it to the line, then add line to the shape-object
$oP->setXY(352,5);
$oL->add($oP);
$shape->add($oL);
# asign the new name (year in your case)
$shape->set('text', $specname);
# add the layer feature to the shape, switch layer on and draw it
$subtitESP->addFeature($shape);
$subtitESP->set('status', 1);
$img=$map->draw();
$subtitESP->draw($img);
More information about the MapServer-users
mailing list