[Mapserver-users] label and mysql
bpicinbono@worldonline.fr
bpicinbono at worldonline.fr
Thu May 1 06:38:12 PDT 2003
label and mysql
Hi everybody
I am still wondering how to label shapes with datas coming
from MySql.
Dan gave me a nice example, but, unfortunately, I can't
manage to make it work. I am working with MapScript 3.6.2
and I wonder if the problem is that MS 3.6.2 doesn't
know the "annotation" type layers ? ? ?.
Here are my settings when I hit the phpinfo page :
MapScript Version ($Revision: 1.104.2.4 $ $Date: 2002/07/08 20:04:58 $)
MapServer version 3.6.2 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP SUPPORTS=PROJ SUPPORTS=TTF SUPPORTS=WMS_SERVER INPUT=TIFF INPUT=EPPL7 INPUT=JPEG INPUT=SHAPEFILE
I am using .phtml and .php pages which are working pretty
similar to the ones of the "gmap75" demo.
Here is the answer that Dan gave me when I first asked
the question :
<<<<<<<<<<<<<<<<<<<<<Start of Dan answer>>>>>>>>>>>>>>>>>>>>>>>
Blaise,
Yes it can be done...here is some simple example code in php/mapscript and the associated map file layer.
Dan
$map = ms_newMapObj($mapPath.$mapFile);
$image=$map->draw();
$testlayer = $map->getLayerByName("labels");
$testpt = ms_newPointObj();
$testpt->setXY( 200, 200 );
$testpt->draw($map, $testlayer, $image, 'labels', 'Hello World');
$testpt2 = ms_newPointObj();
$testpt2->setXY( 300, 200 );
$testpt2->draw($map, $testlayer, $image, 'labels2', 'GoodBye World');
LAYER
NAME labels
STATUS on
TRANSFORM false
TYPE annotation
CLASS
NAME labels
LABEL
type truetype
font verdana-bold
bold
size 8
antialias true
backgroundshadowcolor 51 51 51
backgroundshadowsize 2 2
color 51 51 51
position UR
END
END
CLASS
NAME labels2
LABEL
type truetype
font coopperplate-gothic-bold
size 8
antialias true
backgroundshadowcolor 51 51 51
backgroundshadowsize 2 2
color 51 51 51
position UR
END
END
END
<<<<<<<<<<<<<<<<<<<<<<End of Dan answer>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I am a bit confused about where to put this piece of
php code.
As, in my php page, the only $map->draw() command
is in the GMapDrawMap function, I put it there.
Here is my map file related to the label layer :
<<<<<<<<<<<<<<<<<<<<<Start of my map file>>>>>>>>>>>>>>>>>>>>>>>
################################## layer labels #############
LAYER
NAME labels
STATUS ON
TRANSFORM false
TYPE annotation
CLASS
NAME labels
LABEL
TYPE truetype
FONT fritqat
SIZE 12
COLOR 0 0 255
POSITION UR
END
END
END # Layer
<<<<<<<<<<<<<<<<<<<<<End of my map file>>>>>>>>>>>>>>>>>>>>>>>
and here is the beginning of the GMapDrawMap function where
I inserted Dan's code:
<<<<<<<<<<<<<<<<<<<<<Start of my php page>>>>>>>>>>>>>>>>>>>>>>>
/************************************************************************/
/* function GMapDrawMap() */
/* */
/* Funcion to draw the contains of the map. */
/************************************************************************/
function GMapDrawMap()
{
GLOBAL $gpoMap, $gbShowQueryResults;
GLOBAL $gbIsHtmlMode;
GLOBAL $gszCommand, $gszZoomBoxExt;
GLOBAL $gAppletImgFmt, $gImagesFmt;
GLOBAL $TLayer;
// if ($gbShowQueryResults)
// $img = $gpoMap->drawQuery();
// else
// $img = $gpoMap->draw();
//----------------------------------- test label---------
$map=ms_newMapObj("label_2.map");
$img=$map->draw();
$testlayer=$map->getLayerByName("labels");
$testpt=ms_newPointObj();
$testpt->setXY(100,100);
$testpt->draw($map,$testlayer,$img, 'labels', 'Hello World');
//------------------------------- end test label---------
$url = $img->saveWebImage($gAppletImgFmt, 0, 0, -1);
echo "\n".$gszZoomBoxExt."\n";
printf("<INPUT TYPE=HIDDEN NAME=minx VALUE=\"%f\">", $gpoMap->extent->minx);
printf("<INPUT TYPE=HIDDEN NAME=miny VALUE=\"%f\">", $gpoMap->extent->miny);
printf("<INPUT TYPE=HIDDEN NAME=maxx VALUE=\"%f\">", $gpoMap->extent->maxx);
printf("<INPUT TYPE=HIDDEN NAME=maxy VALUE=\"%f\">", $gpoMap->extent->maxy);
etc,etc,etc..........
<<<<<<<<<<<<<<<<<<<<<End of my php page>>>>>>>>>>>>>>>>>>>>>>>
As I disabled the $gpoMap variable, I can't zoom in,
out,etc anymore, but that's ok until I get my labels
on the map.
But unfortunately, the label 'Hello World' doesn't
show.
In the "$testpt->setXY(100,100);" line, I tried to
put the X,Y of the middle of my mapextent, tried
to comment the " TRANSFORM false" line in my map
file, but this doesn't work neither.
I am wondering what is wrong, and does the version
3.6.2 of MapServer/MapScript support the annotation
type for a layer ?
Thanks a lot for your help, and many thanks for
the MapServer team who are doing a great job. I
am very satisfied with this software.
Blaise
P.S.: Excuse me for the poor text formating but my
company' internet conncetion is rock-age, so I have
to fight to put some text on the internet, sorry
about that.
************ VITE, C'EST LE MOMENT DE VOUS ABONNER A L'ADSL !!! **********
Du 3 avril au 5 mai, série limitée ADSL 128K, cliquez vite ici : http://register.tiscali.fr/adsl/
Offre promotionnelle soumise à conditions, réservée aux nouveaux abonnés ADSL Tiscali.
More information about the MapServer-users
mailing list