<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Comic Sans MS";
        panose-1:3 15 7 2 3 3 2 2 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Times New Roman";
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Comic Sans MS";
        color:blue;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'>I think that
you need to add a class with a label definition to your layer.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'>Here is how I
add a set of virtual layers to my map object before drawing it.&nbsp; I&#8217;m sorry I do
not have time this afternoon to distill it down to just the information you are
looking for.&nbsp; Things to notice that I am using update from string to update my
layer with a class which has style and label information.&nbsp; I have found that
the SYMBOL part of the updateFromText does not work thus the<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'>&nbsp;&#8220;</span></font><font
color=blue face="Courier New"><span style='font-family:"Courier New";
color:blue'>$style-&gt;set('symbolname',$virtualLayers[$i]-&gt;symbol);&#8221;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'>statement which
would seem redundant but is necessary.&nbsp; Let me know if you cannot get the
required information from this example and I&#8217;ll help more.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>function
addVirtualLayers($ms, $virtualLayers) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp; if
(isset($virtualLayers)) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp; $newLayer =
array();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp; for ($i=0; $i
&lt; sizeof($virtualLayers); $i++) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $newLayer[$i]
= ms_newLayerObj($ms);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$newLayer[$i]-&gt;set('type',$virtualLayers[$i]-&gt;layerType);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#echo('layer type='.$virtualLayers[$i]-&gt;layerType);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if($virtualLayers[$i]-&gt;layerType == MS_LAYER_POINT) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $string =
'LAYER NAME VirtualLayer'.$i.' CLASS NAME SELECTEDPTS STYLE SYMBOL CROSS COLOR
255 0 200 SIZE 8 END LABEL TYPE truetype MINFEATURESIZE 50 MINDISTANCE 0
POSITION CR FONT vera SIZE 7 COLOR 255 0 255 END END END';<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if
($virtualLayers[$i]-&gt;layerType == MS_LAYER_POLYGON) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$string =
'LAYER NAME VirtualLayer'.$i.' CLASS NAME SELECTEDPOLYGONS STYLE OUTLINECOLOR
255 0 200 WIDTH 3 END LABEL TYPE truetype MINFEATURESIZE 50 MINDISTANCE 0
POSITION LC FONT vera SIZE 7 COLOR 255 0 255 END END END';<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if
($virtualLayers[$i]-&gt;layerType == MS_LAYER_LINE) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $string =
'LAYER NAME VirtualLayer'.$i.' CLASS NAME SELECTEDPOLYGONS STYLE COLOR 255 0 0
WIDTH 3 END LABEL TYPE truetype MINFEATURESIZE 50 MINDISTANCE 0 POSITION LC
FONT vera SIZE 7 COLOR 255 0 255 END END END';<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$newLayer[$i]-&gt;updateFromString($string);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
#echo('layer type2 ='.$newLayer[$i]-&gt;type);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$newLayer[$i]-&gt;set('status',MS_ON);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $class =
$newLayer[$i]-&gt;getClass(0);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>#echo($virtualLayers[$i]-&gt;class);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$class-&gt;updateFromString($virtualLayers[$i]-&gt;class);&nbsp; //returns
MS_SUCCESS | MS_FAILURE<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if(isset($virtualLayers[$i]-&gt;symbol)) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $style =
$class-&gt;getStyle($class-&gt;numstyles-1);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$style-&gt;set('symbolname',$virtualLayers[$i]-&gt;symbol);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $shape =
ms_shapeObjFromWkt($virtualLayers[$i]-&gt;shapeWkt);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$shape-&gt;set('text', $i);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
if(isset($virtualLayers[$i]-&gt;labelText)) {<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$shape-&gt;set('text', $virtualLayers[$i]-&gt;labelText);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
$newLayer[$i]-&gt;addFeature($shape);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>&nbsp; }<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>}<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'>?&gt;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Courier New"><span
style='font-size:12.0pt;font-family:"Courier New";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 color=blue face="Comic Sans MS"><span
style='font-size:12.0pt;font-family:"Comic Sans MS";color:blue'><o:p>&nbsp;</o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
mapserver-users-bounces@lists.osgeo.org
[mailto:mapserver-users-bounces@lists.osgeo.org] <b><span style='font-weight:
bold'>On Behalf Of </span></b>Helen Eskina<br>
<b><span style='font-weight:bold'>Sent:</span></b> Thursday, December 03, 2009
11:13 AM<br>
<b><span style='font-weight:bold'>To:</span></b>
mapserver-users@lists.osgeo.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> [mapserver-users] How to
set Labels dynamically?</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Hello,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I couldn&#8217;t find documentation how to set the text labels dynamically
using MapScript. <o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>My application should show points with labels on the map. Points and labels
are obtained dynamically from the database or some text file.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I add the points to the layer and draw layer as following:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>$my_point = ms_newpointObj();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$my_point-&gt;setXY(-75.895, 45.9227);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$my_point-&gt;project($projInObj,$projOutObj);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$line = ms_newLineObj();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>$line-&gt;add($my_point);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$shape = ms_newShapeObj(MS_SHAPE_POINT);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$shape-&gt;add($line);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$shape-&gt;set(text, 'new point');<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$daLayer-&gt;addFeature($shape);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>$image=$map-&gt;draw();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>$daLayer-&gt;draw($image);<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;$image_url=$image-&gt;saveWebImage();<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Points are displayed on the map, but no text. What am I doing wrong?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>I will appreciate any help,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Helen<o:p></o:p></span></font></p>

</div>

</body>

</html>
<P><FONT SIZE=2 FACE="Arial">No virus found in this incoming message.<BR>
Checked by AVG - www.avg.com<BR>
Version: 9.0.709 / Virus Database: 270.14.91/2542 - Release Date: 12/03/09 02:32:00<BR>
</FONT></P>

<P><FONT SIZE=2 FACE="Arial"> </FONT> </P>