Mapscript question

Stephen Lime steve.lime at dnr.state.mn.us
Thu Dec 23 13:52:58 EST 1999


Remember MapScript is NOT mapserv. You can build mapservish apps with it, and can do things you simply
couldn't do with mapserv. Here's one simple way to process a request for a set of layers that mimics the way
mapserv does it:

...
$cgi = CGI;
$map = new mapObj('test.map');

@user_layers = $cgi->param('layer');

for($i=0; $i<$map->{numlayers}; $i++) { # for all layers
    $layer = $map->getLayer($i); # get the layer object
    if($layer->{status} != $mapscript::MS_DEFAULT && $layer->{status} != $mapscript::MS_QUERY) { # leave these layers alone
        $layer->{status} = $mapscript::MS_OFF; # by default
        foreach (@user_layers) {
            if($_ eq $layer->{name} || $_ eq $layer->{group}) { # user wants this layer
                $layer->{status} = $mapscript::MS_ON;
                break;
            }
        }
    }
}

# now modify extents and whatever else you might want to do

$img = $map->draw(); # all layers defined so draw the map

# now save the map some place or even send it back to the client using Mime: image/gif.
...

This chunk of code simply turns all layers off, then sets those selected by the user to on. It ignores
DEFAULT and QUERY layers. It may be that this is so common that we'll want to set up a separate
module mapscript::mapserv to mimic a few mapserver code pieces.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Paul G. Allen" <pgallen at randomlogic.com> 12/23/99 12:40PM >>>
I'm a little at a loss.

If I have a multi-selection list box on my web page for selecting layers to
display, how would I draw these layers using mapscript?

PGA




More information about the mapserver-users mailing list