[MapServer-users] Is processLegendTemplate() not supported in PHP/Mapscript 8
Fujioka (Duke)
efujioka at duke.edu
Wed Apr 16 14:45:41 PDT 2025
Hello,
I have been finally upgrading the existing mapping application from
PHP/Mapscript 5.x to SWIG Mapscript 8.0.
In the previous version, I used
$legend = $oMap->processLegendTemplate(array());
but the parameters for processLegendTemplate change in Mapscript 8. So,
I tried this:
$names = array();
$values = array();
$legend_buffer = $oMap->processLegendTemplate($names, $values, 0);
Then, I got an error "Uncaught TypeError: Expected SWIGTYPE_p_p_char for
argument 2 of mapObj_processLegendTemplate".
Because I had no idea what this meant, I asked ChatGPT and Copilot. Both
suggested to use "an array of strings". ChatGPT showed me like:
$names = new mapscript\stringArray(0);
$values = new mapscript\stringArray(0);
and Copilot suggested like:
$names = new SWIG_StringArray(3);
$values = new SWIG_StringArray(3);
but either stringArray() or SWIG_StringArray() is not defined. Then,
they indicated that processLegendTemplate() was not implemented in
PHP/Mapscript 8 and suggested me to find an alternative way to generate
legend.
So, is processLegendTemplate() not available in PHP/Mapscript?
Has anyone figured out a workaround?
Here is my system:
PHP Version 8.3.19
MapServer version 8.0.1
OS: Ubuntu
And one of the templates I use looks like:
[leg_class_html opt_flag=13]{class_name:"[leg_class_name]",
icon:"[leg_icon]", title: "[leg_class_title]"},[/leg_class_html]
# This one becomes a JSON object and is sent to the browser where
Javascript parses it.
Thanks,
Ei
--
========================
Ei Fujioka
Research Scientist
Nicholas School
Duke University
(919) 684-3518
efujioka at duke.edu
========================
More information about the MapServer-users
mailing list