[mapserver-users] TIP: Dynamic Legend (I did it!)
Antti.Roppola at brs.gov.au
Antti.Roppola at brs.gov.au
Wed Sep 11 21:44:50 PDT 2002
Hi all,
Here's another one:
http://mapserver.gis.umn.edu/wilma/mapserver-users/0201/msg00241.html
Since then I added interleaved legends by adding something like this
the the inside of the main loop:
if($checked) {
$layer_legend = ms_newMapObject("$my_map");
$img = $layer_legend->prepareImage();
$layer = $layer_legend->getLayer($n);
$layer->set("status", 1);
$img = $layer_legend->drawLegend();
$url = $img->saveWebImage(MS_PNG, 0, 0, 0);
printf("<IMG SRC=%s><BR>\n", $url);
}
Paul wrote:
> Chip, have you thought about what happens when layers turn on and off
> due to scales of visibility? A pretty common problem we are seeing is
> that people set certain layers to appear as the user zooms in, but if
That's an easy addition, pass the selected layers as an array and use the
state of the array to switch layers on and off, it's pretty easy to add a
test to see if the scale is OK, and gray out the layer description.
I also check layer name so that I can have a composite layer that is (for
example) a set of point and line layers such as roads and towns and have them
controlled as a single entity and only appear once in the control.
Cheers,
Antti
-----Original Message-----
From: Hankley, Chip [mailto:Chip.Hankley at GASAI.Com]
Sent: Thursday, 12 September 2002 6:47 AM
To: MapServer List (E-mail)
Subject: [mapserver-users] TIP: Dynamic Legend (I did it!)
OK... I figured out how to do this... and put the code in the Wiki at the
following location:
http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPDynLegend
(There is a link under the Examples section of PHP MapScript)
Basically what it does is reads a mapfile, and creates a legend / layer
control on the fly. Furthermore, it sets up the controls so that state is
maintained with only a couple of lines of code... and any changes to the
mapfile (i.e. additional layers, changes to layers) are automatically
reflected in the application (i.e. there's no need to make changes to the
PHP part of the application).
Hope this is useful to someone!
Chip Hankley
More information about the MapServer-users
mailing list