[MapServer-users] PHP Mapscript: how to clone layers

Jan Hartmann j.l.h.hartmann at gmail.com
Mon Nov 27 08:59:29 PST 2023


Yes, that's it. Thanks, Seth!

It was an insidious migration problem. The old way of cloning a layer 
($l2 = new layerObj($oMap,$l1);) still works, but ignores the second 
parameter. So you get a default new layer, with STATUS OFF. I filled 
every member but that. No wonder the layers didn't turn on. Could this 
function be made to fail when called with two parameters?
On 26/11/2023 21:20, Seth G wrote:
> Hi Jan,
>
> I'm not a PHP MapScript user but you should be able to use:
>
> $l2 = $l1->cloneLayer();
>
> As per the note at the following link - "In the Java & PHP modules this method is named cloneLayer. "
> https://mapserver.org/mapscript/mapscript-api/stub/mapscript.layerObj.html#mapscript.layerObj.clone
>
> I'm guessing there is a clash with the a reserved keyword in PHP so the method needs a different name.
>
> Seth
>
> --
> web:https://geographika.net  &https://mapserverstudio.net
> twitter: @geographika
>
> On Sun, Nov 26, 2023, at 7:38 PM, Jan Hartmann via MapServer-users wrote:
>> Hi,
>>
>> In previous versions of PHP MapScript a new layer was defined as:
>>
>> $l2 = new layerObj($oMap,$l1);
>>
>> $l1 is the base layer from which $l2 is copied.
>>
>> In MapScript SWIG the second parameter has disappeared. $l2 has to be
>> cloned from $l1, and then inserted into the map. With PHP-MapScript this
>> should be:
>>
>> $l2 = $l1->clone();
>> $oMap->insertLayer($l2);
>>
>> But there is no PHP-MapScript function layerObj::clone. What do I miss?
>>
>> Jan
>>
>>
>>
>> _______________________________________________
>> 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/20231127/ae1d246f/attachment.htm>


More information about the MapServer-users mailing list