I'm very new with mapScript, I'm looking to change a layer order with mapScript. My ms_newMapObj is a merge of many mapfile so I don't know the index of the layer I want to move up.

I haven't find how to associate the layer with the drawing index given by getLayersDrawingOrder. This method returning only a list of index but what i realize, it's that the layer object haven't an index properties. I know the method moveLayerUp but it needs an index in parameter too.

Here is my code to get the layer I want to move up.

 $allLayers = $oMapFinal->getAllLayerNames();

foreach ($allLayers as $evalLayer){
    $layer = $oMapFinal->getLayerByName($evalLayer);
    if($layer == MY CONDITION)
       //change drawing order

Finally I got it, it seems that getAllLayerNames and getLayersDrawingOrder have the same order.

So here is my code:

 $allLayers = $oMapFinal->getAllLayerNames();

foreach ($allLayers as $index => $evalLayer){
    $layer = $oMapFinal->getLayerByName($evalLayer);
    if($layer == MY CONDITION) {
       $arrLayOrder = $oMapFinal->getLayersDrawingOrder();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.