Example 2.2: Layer Control

Select Layers: State Boundaries  Water Features  
Select Background:
Map Mode:
Map Control:

Back to Example 2.1 | Back to Section 2 | Tutorial home | Proceed to Example 2.3

Being able to turn map layers on and off is a standard feature of web mapping applications. There are many ways to accomplish this using form objects as control. You can use the drop box/menu, check boxes, and/or radio buttons. In this example you'll see how to implement layer selection using check boxes and drop boxes.

Here's the mapfile:

Notice how the layer STATUS has been changed to OFF except for the "States" polygon background. The states background was left as default so our map will always have something when drawn without any layers turned on. The users of our application should have control of which layers to turn on or leave off.

You'll understand how the layers are turned on/off by MapServ if you look at the source code of our HTML template.

Back to Example 2.1 | Back to Section 2 | Back to the Sections Page | Proceed to Example 2.3