Dynamic Maptitle

Gerjan Walrecht WalrechtG at VERTIS.NL
Wed Jul 27 07:44:58 EDT 2005


List,

With the help of Martin Meirink (Thank you, Martin) I've got what I needed.
The solution is somewhat different then Sefanie's solution:

In the mapfile add an empty feature layer:

----------------Begin part of mapfile ----------------------------
LAYER
  NAME titel
  STATUS DEFAULT
  TRANSFORM FALSE
  TYPE ANNOTATION
  CLASS
    LABEL
     TYPE TRUETYPE
     FONT "arial"
     SIZE 11
     ANTIALIAS TRUE
     COLOR 0 0 0
     backgroundcolor 255 204 204 
     backgroundshadowcolor 255 153 204 
     backgroundshadowsize 5 3  
    END
  END
END

----------------End part of mapfile ----------------------------

In the url you can add:
  &map_titel_feature=new
To create a new feature

Also add:
  &map_titel_feature_points=360+8
To place a (label) point in the new feature

Last but not least add:
  &map_titel_feature_text=+your+title+here+++
To add the title

In the last part, one can also use parameters which was what we needed
In the mapfile you can define the label settings like color, etc.


Gerjan

-----Original Message-----
From: Stefanie Weykam [mailto:sweykam at teleline.es]
Sent: 26 juli 2005 16:34
To: UMN MapServer Users List
Cc: Gerjan Walrecht
Subject: [SPAM: 8.0/6.0] RE: Dynamic Maptitle



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);

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050727/ea46cdc6/attachment.html


More information about the mapserver-users mailing list