[mapserver-users] Multiple LabelItems from dropdown?

Stephen Lime steve.lime at dnr.state.mn.us
Mon Aug 6 14:33:40 EDT 2001


Basically you either:

  - write a function run after the page has loaded to set the pulldown correctly or
  - use javascript to write the pulldown control in the body of the page

Using the former would be like:

  function set_airport_labelitem(list) {
    var current_value = '[map_airport_labelitem]';

    for(var i=0; i<list.length; i++)
      if(list.options[i].value == current_value)
        list.options[i].selected = true;
  }

and in <body ...> tag you'd add onload="set_airport_labelitem(document.formname.map_airport_labelitem)"
or something like that. You'd write the HTML for the pulldown as normal with nothing or perhaps a default
value selected and the javascript takes care of initializing it. If map_airport_labelitem is passed into MapServer
then [map_airport_labelitem] will contain it's value for use in a template.

Steve

Stephen Lime
Internet Applications Analyst

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

>>> "Mark Abernathy" <WMABERN at gwm.sc.edu> 08/06/01 11:05AM >>>
This sounds like a better alternative as a few dozen almost duplicated layers would make the map file very large.

Any small examples of the code neccessary to do this would be greatly appreciated as I am somewhat of a newbie in terms of coding, esp. java! Thanks for the input.

Mark

~~~~~~~~~

Another option would be to change the label item on-the-fly. You can
use the CGI variable map_airport_labelitem for that purpose. You only
need one layer then. You'll have to write a tiny bit of javascript code
to make that control sticky but that's about it.

Steve

Stephen Lime
Internet Applications Analyst

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

>>> Puneet Kishor <pkishor at GeoAnalytics.com> 08/03/01 12:58PM >>>
Hi Mark,

The quickest way that come to my mind is...

make a separate layer for each of the labels... that is, one airport layer
with airport name as labelitem, another airport layer with faa id as label.
Turn the status to off for all of them.

then use the form to grab the labelitem and turn that specific layer on by
setting its status to on.

hth.

pk/

--
Puneet Kishor
pkishor at geoanalytics.com 
www.geoanalytics.com 

GeoAnalyics, Inc.
1716 Fordem Ave
Madison WI 53704

-----Original Message-----
From: Mark Abernathy [mailto:WMABERN at gwm.sc.edu] 
Sent: Friday, August 03, 2001 11:12 AM
To: mapserver-users at lists.gis.umn.edu 
Subject: [mapserver-users] Multiple LabelItems from dropdown?


Hi folks,
I have an airport layer with different classes of airports within it
determined by a SYMBOL attribute in the shape file. I would like to be able
to choose the Attribute to display at run time by feeding the labelitem i.e
FAAID or Airport Name from a dropdown list box on my html form.  
In other words, I want the user to be able to diplay the Airport name if
they want, or the FAA Id, etc... chosen from a dropdown. Can this be done? 

I haven't seen a question on this or an example of this in the archives. 

Does anyone have an example of doing this and what variable should I be
passing to the map file and what is the syntax of that, please? Also, any
suggestions on the coding of the html drop down? Thanks for any assistance.
Below is a snip of my map file.


# Start of AIRPORT Layer
LAYER
  NAME AIRPORT
  TYPE Point
  DATA AIRPORT
  STATUS DEFAULT
  
  LABELITEM FAAID
  CLASSITEM "SYMBOL"
     
   CLASS  
      EXPRESSION /1/
      NAME "Public Airport"
      SYMBOL 13 
      SIZE 11           # legend symbol size
      COLOR 102 204 000  # legend symbol color - green
    
     LABEL
      COLOR 0 0 0
      OUTLINECOLOR 255 255 153
      POSITION AUTO
      SIZE small
      PARTIALS TRUE
      BUFFER 2
     END
   END # CLASS




More information about the mapserver-users mailing list