Is it possible to call a draw on a mapFile with a list of layers to include with mapScript?
I have a bunch of layers defined on my mapfile but I don't want to call all of them. I don't use "STATUS DEFAULT", i would like to call specifics layers like we can do with the get parameters, for example: "LAYERS=LAYER1,LAYER2,LAYER3&...."

1 Answer
1

With PHP-MapScript, you can get all layer names as an array.
You can make an array of the layers wish to enable, using the layer name.

This is not the most elegant solution, and there is likely a better method supported through the API, but quick and dirty you can just step through the entire list of layers and disable them and only enable the ones you want.

Step through both arrays, disabling all layer, but enabling if there is a match in the array containing the lists you wish to enable.

Good idea but I realize that my layers are defined with INCLUDE in my mapfile, so I can't change the STATUS (I can't change the layer's file, only the parent mapfile). Example: In my MapFile I have INCLUDE 'productions.map'. This incclusion is a file who contain the list of productions layers.
– MichaelOct 5 '15 at 17:27

I'm not sure that would effect this answer. I think layer names are still retained through the include (documentation is scarce). You could always run getAllLayerNames, print it, and see what is returned.
– ThomasOct 5 '15 at 17:36

You're right for the list of layer. I was thinking that it can change something. I try your code but I always get the same image (my layers are not activate). Not sure of the syntax of the status update. I use my own try but same result. I try: $layer->updateFromString('LAYER STATUS ON END'); and $layer->set("status", MS_ON); I debbuged the code to be sure that the "setStatus" is executed and it was.
– MichaelOct 5 '15 at 18:03

I add $layer->open() before and after the method to change status and the value stay "0"
– MichaelOct 5 '15 at 18:19

Just a quick check, try setting to MS_DEFAULT and not MS_ON.
– ThomasOct 5 '15 at 18:46