[mapserver-users] How to get Layers By Group

Gregor at HostGIS gregor at hostgis.com
Thu Feb 5 20:00:55 PST 2009


Venkat Rao Tammineni wrote:
>    How  can I retrieve layers  by Group Name. And how to loop these 
> layers based on group. Where I can able to  switch on and swatch off the 
> layers based on Group.

A group is just a "fake layer" with many layers. You request a group in 
the same way as you would a layer; the only change is that you use the 
group name and will get all the layers mixed together.

Example:

LAYER
   NAME "roads"
   GROUP "usamap"
END
LAYER
   NAME "lakes"
   GROUP "usamap"
END
LAYER
   NAME "cities"
   GROUP "usamap"
END

I would then request "layers=usamap" and magically get all three layers 
merged into one request.


> I have Group property in my mapfile .but I don’t 
> know how to get layers and populate some control

As to generating a control, that's the same as with layers as well 
except that you would use getAllGroupNames() instead of 
getAllLayerNames() But that depends on your own programming style and goals.

-- 
Gregor Mosheh / Greg Allensworth    BS, A+, Network+, Security+, Server+
System Administrator, Lead Programmer
HostGIS development & hosting services, http://www.HostGIS.com/

"Remember that no one cares if you can back up,
  only if you can restore." - AMANDA



More information about the MapServer-users mailing list