Help! html legend problems

Steven Monai stevem at SPATIALMAPPING.COM
Wed Dec 14 11:40:43 EST 2005


Joanne:

So your only problem now is that you want your layers to be initially ON.
Two methods immediately come to mind.

(1) Use an initialization page that leads into your MapServer application.
Here is a minimal example:

<html>
<head><title>MapServer Start!</title></head>
<body>
<form method="POST" action="/cgi-bin/mapserv">
<input type="hidden" name="map" value="/path/to/my/mapfile.map" />
<input type="hidden" name="mode" value="browse" />
<input type="hidden" name="layers" value="layer1,layer2,layer3" />
<input type="submit" name="submit" value="Start!" />
</form>
</body>
</html>

Pressing the Start! button launches into your MapServer web application,
with the layers "layer1", "layer2", and "layer3" initially ON (and all
other non-DEFAULT layers OFF).

(2) Instead of a Start page, you could just specify the layers that you
want initially on in the URL you use to launch your application. E.g.:

http://www.myserver.com/cgi-bin/mapserv?
map=/path/to/my/mapfile.map&mode=browse&layers=layer1,layer2,layer3

HTH,
-SM
--

On Wed, 14 Dec 2005 16:00:23 -0000, joanne cook <j.cook at OXFORDARCH.CO.UK>
wrote:

>Hi Steven,
>
>When the layers are not set as hidden cgi variables and I zoom into scale,
the new legend items first appear off rather than on, and don't display on
the map. However, when switched on they do maintain their status when the
submit button is clicked. The legend is definitely inside the form as well.
>
>Thanks for your perserverance!
>
>Jo
>
>-------------------------------------------
>Joanne Cook BSc MLitt AIFA
>Information Systems Coordinator
>Oxford Archaeology North
>-------------------------------------------
>
>________________________________
>
>From: Steven Monai [mailto:stevem at spatialmapping.com]
>Sent: Wed 14/12/2005 15:56
>To: joanne cook
>Cc: MAPSERVER-USERS at LISTS.UMN.EDU
>Subject: RE: Help! html legend problems
>
>
>
>Joanne:
>
>Try removing the layers from your hidden cgi variables. There should be no
>need for them anyway, since you're using the HTML legend to control the
>layers' on/off status. Also, be certain that the legend is rendered inside
>your <form>, so that the checkboxes contribute their values to the web-page
>submission.
>
>-SM
>--
>
>-----Original Message-----
>From: joanne cook [mailto:j.cook at oxfordarch.co.uk]
>Sent: Wednesday, December 14, 2005 3:47 AM
>To: Steven Monai
>Cc: MAPSERVER-USERS at LISTS.UMN.EDU
>Subject: RE: Help! html legend problems
>
>Hi Steven,
>
>Thanks for the response. I have removed the html head and foot tabs- they
>were important at one point but not anymore. I also changed the name of the
>checkbox to layer, as you suggested. The layers are all on in the map file,
>and defined as hidden cgi variables in my web page. Now, when I zoom into
>scale, the new layers appear switched on, which is good, but if I uncheck
>the check boxes and click the submit button they stay switched on, whereas
I
>want them to turn off...
>
>All the best
>
>Jo
>-------------------------------------------
>Joanne Cook BSc MLitt AIFA
>Information Systems Coordinator
>Oxford Archaeology North
>-------------------------------------------
>
>________________________________
>
>From: Steven Monai [mailto:stevem at SPATIALMAPPING.COM]
>Sent: Tue 13/12/2005 16:43
>To: MAPSERVER-USERS at LISTS.UMN.EDU; joanne cook
>Subject: Re: Help! html legend problems
>
>
>
>Joanne:
>
>Change the name of your checkbox from "layer_status" to simply "layer".
>That should allow the MapServer CGI recognize it. Also, if it is your
>intention to embed the legend within a map tempate (via: <table>[legend]
></table>, for example), then you ought to remove the <html><head>... tags,
>as they will only serve to confuse the browser.
>
>Did you resolve your layer on/off problem by changing your layers' status
>from ON to DEFAULT? If so, change them back to ON (or OFF), otherwise the
>checkboxes in your legend will be ignored.
>
>HTH,
>-SM
>--
>
>On Mon, 12 Dec 2005 09:37:39 -0000, joanne cook <j.cook at OXFORDARCH.CO.UK>
>wrote:
>
>>Hi Everyone,
>>
>>I have got myself into a terrible mess with html legends and would
>appreciate some assistance, as nothing I do seems to work. I am trying to
>implement a legend with check boxes for layer control, that only displays
>layers that are in scale on the map. So far so good. My legend template is
>shown below:
>>
>>[leg_layer_html Opt_Flag=14]
>><html>
>><head>
>><title></title>
>></head>
>><body>
>><tr bgcolor="#FFFFFF">
>>  <td align="center">
>>    <input type="checkbox" name="layer_status" value="[leg_layer_name]"
>[if name=layer_status oper=neq value=0]CHECKED[/if]>
>>  </td>
>>  <td><img src="[leg_icon height=15 width=15]" height=15 width=15></td>
>> <td><font face="Arial, Helvetica, sans-serif" size="2">[if
>name=layer_name oper=neq value=][leg_layer_name][/if][if name=layer_name
>value=]* Name Not Set*[/if]</font></td>
>></tr>
>></body>
>></html>
>>[/leg_layer_html]
>>
>>My first problem was that when I zoomed in on the map to a scale at
>>which
>new layers became visible, they appeared switched off in the legend. All
the
>layers in my map file have status ON. I resolved that, or so I thought, but
>now when I try and switch layers off in the legend, and refresh my map
(with
>a form submit button) they just stay switched on. Also, I don't really
>understand the relationship between having layers declared as cgi variables
>in my web page and the behaviour of the legend.
>>
>>I have searched the documentation on this, and I'm sure it must be
>something very simple that I am missing, so I would really appreciate it if
>someone could help me out.
>>
>>Many thanks
>>
>>Jo
>>
>>-------------------------------------------
>>Joanne Cook BSc MLitt AIFA
>>Information Systems Coordinator
>>Oxford Archaeology North
>>-------------------------------------------
>>
>>
>>This message has been scanned for viruses by BlackSpider MailControl -
>www.blackspider.com



More information about the mapserver-users mailing list