[mapserver-users] adding labels via php mapscript

Stephen Lime steve.lime at dnr.state.mn.us
Wed Sep 5 15:50:41 PDT 2001


Assuming your allowing for cached labels you need to call the drawLabelCache method once your done with all drawing (and before outputing the image of course). This applies to all layer types. Unless specificly disabled drawing of the cache takes place post feature rendering. The mapObj draw method takes care of this for you but in this case you must manually call it.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> "A. Giacomelli" <andreag at crs4.it> 09/05/01 12:35 PM >>>
Hi,

I'm talking about adding labels/annotation dynamically via a
ms_point->draw method.

I know this has already been discussed on the list, and I have the
postings from the archives, but it's not getting to work.
I would appreciate if you could check the code snippets included.

There was also a similar posting a couple of weeks ago, but I think it
is not related to the same version of mapserv, and was referring to
polygons, rather than points, so  I would like to double check...

I am currently working on 3.4 + php4.

TIA for any suggestions,
===============================================

Here goes the code. It's supposed to write MYSTRING in the middle of my
image.
===============================================

PHPmapscript part:
......
$mylayer = $gpoMap->getLayerByName("credits");
$txtp = ms_newpointobj();



$txtp->setXY( $myMap->extent->miny + ($gpoMap->extent->max -
$gpoMap->extent->minx)/2 , $gpoMap->extent->miny + ($gpoMap->ex
tent->maxy -$gpoMap->extent->miny )/2);

//$txtp->draw($myMap,$mylayer,$img,"credits","MYSTRING");
$txtp->draw($myMap,$mylayer,$img,0,"MYSTRING");
......

-------------------------------------------------
MAP file
......
LAYER
   NAME credits 
   TYPE POINT   # TRIED ALSO W/ ANNOTATION
   STATUS ON
   CLASS
     NAME credits
        COLOR 0 0 255
        LABEL
          COLOR 0 0 255
          FORCE TRUE
          TYPE TRUETYPE
          FONT fritqat-italic
          MINSIZE 15
          MAXSIZE 30
        END
   END
END
.....
-- 
=========================================
Andrea Giacomelli
Centre for Advanced Studies, Research and
Development in Sardinia

http://www.crs4.it/~andreag
=========================================




More information about the MapServer-users mailing list