[Mapserver-users] How to select layer to display from a pop-up list?

Sean Gillies sgillies at frii.com
Mon Nov 17 18:46:25 EST 2003


On Monday, November 17, 2003, at 02:28  PM, J. Tomasz Giermakowski  
wrote:

> Hello,
>
> I have a newbie question: i need to be able to select one to five  
> layers
> to display from a list of over 120. They are polygons of distribution
> maps. Do I have to setup a template .map file with 124 shapefiles and
> layer definitions or a shapefile with 124 features (they are polygons)?
> the first solution would not be hard, but the colors have to be
> dynamically created so that if someone wants to look at 5 layers at the
> same time, they are shown in different colors. Would PHP solve that
> problem? Can you pass PHP variables to the .map file?
>
> thanks ahead.
> _______________________________________________________________________ 
> ________
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
> ^^^^^^^^
> J. Tom Giermakowski
> Division of Amphibians and Reptiles
> Museum of Southwestern Biology		tel: 505.277.5130
> MSC03 2020, Castetter Hall 		fax: 505.277.0304
> University of New Mexico		email: tomas at unm.edu
> ALBUQUERQUE, NM 87131-0001, USA         web:  
> http://www.unm.edu/~msbherp
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
> ^^^^^^^^
> ----------------------------------------------------------------------- 
> --------


Either of your solutions can be implemented with MapServer.  I like the
second one better if all your 120+ species (I assume from your  
affiliation
with the Museum?) are similarly attributed.

MapServer allows you to to "rewrite" some map file parameters, and this
is explained here:

http://mapserver.gis.umn.edu/doc40/cgi-reference.html#mapfileURL

So, if your layer is named 'LAYER' and features have an attribute
named 'ATTR' and you wanted to map the features for which ATTR is 'A',
'B', or 'C', you would use a URL like

http://.../ 
mapserv?map_LAYER_classitem=ATTR1&map_LAYER_class_0_expression="A"&map_L 
AYER_class_1_expression="B"&map_LAYER_class_2_expression="C"

In your map file you'd have styles already set for up to 5 different  
classes.
The URL above dynamically assigns features into the existing classes.   
You
should also be able to alter the styles of existing classes in a  
similiar
way by appending something like this:

&map_LAYER_class_0_styles_color_red=RED&map_LAYER_class_0_styles_color_g 
reen=GREEN&map_LAYER_class_0_styles_color_blue=BLUE...

to the URL.  In the MapServer tutorial there are some better examples  
of this.

Hope this helps,
Sean

--
Sean Gillies
sgillies at frii dot com
http://www.frii.com/~sgillies




More information about the mapserver-users mailing list