Enable/disable a group of layers (workaround)

Stephen Lime steve.lime at dnr.state.mn.us
Fri Apr 21 13:54:51 PDT 2000


This not working is an oversight in the source. It'll be fixed in the next release...

Groups are usefull when using URL base map file mods or when in mapscript.
Otherwise a unique layer name is NOT neccessary. So you could name all
that layers 'roads' and dump the group attribute for now and the checkbox 
should be sticky as planned.

Steve

Stephen Lime
Internet Applications Analyst

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

>>> Berend Veldkamp <berend.veldkamp at aris.nl> 04/21/00 09:43AM >>>
OK, I found a workaround myself, using JavaScript:

<SCRIPT LANGUAGE="JavaScript"><!--

function CreateCheckBox (layername)
{
  theLayers = "[layers]";
  if ((theLayers.length > 0) && (theLayers.indexOf (layername) > -1))
    theResult = " checked";
  else
    theResult = " ";
  theResult = "<INPUT type=checkbox name=layer value=" + layername +
theResult + "> ";
  document.write (theResult);
}

//--></SCRIPT>

and in my HTML code:

....

<SCRIPT LANGUAGE="JavaScript"><!--
      CreateCheckBox ("allroads");
//--></SCRIPT>
All Roads<BR>

....

Still, there must be a better way...
Berend


Berend Veldkamp wrote:

> Here's a question concerning groups of layers.
> What I'm trying to do, is to enable/disable a group of layers with one
> checkbox. When I do this with a separate layers, there's no problem,
> this works:
>
> <INPUT type="checkbox" name="layer" value="road1" [road1_check]>Minor
> Roads<BR>
> <INPUT type="checkbox" name="layer" value="road2"
> [road2_check]>Highway<BR>
> <INPUT type="checkbox" name="layer" value="road3" [road3_check]>Other
> Roads<BR>
>
> When I group multiple layers in a group (in my .map file), it works as
> well, but the checkbox is always unchecked after the map is drawn.
>
> <INPUT type="checkbox" name="layer" value="allroads"
> [allroads_check]>Roads<BR>
>
> Any ideas, anyone?
> TIA, Berend
>
> --

--






More information about the MapServer-users mailing list