0

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

1 Answer 1

1

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();
       unset($arrLayOrder[$index]);
       $oMapFinal->setLayersDrawingOrder(array_merge([$index],$arrLayOrder));
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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