[mapserver-users] MapScript PHP label with expression and linebreak
Jean-Philippe Chenel
jp.chenel at live.ca
Sat Mar 28 07:48:35 PDT 2020
Hi Steve,
Using MapScript PHP API, WRAP is a integer member.
I've also tried this, but the map isnt rendering.
$labelObj->set("WRAP", "@");
Thank you very much for your help
Jean-Philippe
________________________________
De : mapserver-users <mapserver-users-bounces at lists.osgeo.org> de la part de Stephen Woodbridge <stephenwoodbridge37 at gmail.com>
Envoyé : 28 mars 2020 10:43
À : mapserver-users at lists.osgeo.org <mapserver-users at lists.osgeo.org>
Objet : Re: [mapserver-users] MapScript PHP label with expression and linebreak
When labeling with linebreaks, I insert an unique character like '@', so
"[field1]@[field2]" and then on the label block add
WRAP "@"
Try that and see if it works for you.
-Steve W
On 3/28/2020 10:22 AM, Jean-Philippe Chenel wrote:
> Hi,
>
> Using MapScript PHP API, I want to create a label object (using
> tostring expression) and put 2 columns with a linebreak between them.
> The example above is working well on a single line, but I don’t know
> how to make the linebreak (carriage return).
>
> $text = "(tostring([vol],'%.2f')+'[vol]')";
> $classObj = new classObj($layer);
> $classObj->setText($text);
> $classObj->addLabel(CreateNewLabel($labelProperties));
>
> I've tried multiple combination of \r\n but none of them work (map
> rendering work, but the label completely disappear).
> $text = "(tostring([vol],'%.2f') + '\r\n[vol]')";
> $text = "(tostring([vol],'%.2f') + '\r\n' + '[vol]')";
>
> If I don’t use the expression, the line break work
> $text = "'[vol]\r\n[vol]'";
>
> By the way, the TEXT property is on the classObj, the setText method
> doesn’t work on the labelObj.
>
> With best regards,
>
> MapServer 7.4.4 (under ubuntu 16.04)
> PHP 5.6.40
>
> Jean-Philippe
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20200328/32236817/attachment.htm>
More information about the MapServer-users
mailing list