[mapserver-users] MapScript PHP label with expression and linebreak

Jean-Philippe Chenel jp.chenel at LIVE.CA
Sat Mar 28 07:22:39 PDT 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20200328/8ca606f2/attachment.html>


More information about the mapserver-users mailing list