Arnd Wippermann wrote:
Hello Steve,

Someting I have always searched, but to lazy to look into the documentation.
This parameters one can also set with cgi.
Thanks for the info

I have not tried this, but I think the syntax would be something like:

map_<layer_name>_labelrequires=0   to turn off the the labels.

replace <layer_name> with the name of the layer. Probably best if you do not have spaces in the layer name.

-Steve W.

Mit freundlichen Grüssen

Arnd Wippermann
http://gis.ibbeck.de/ginfo/



-----Ursprüngliche Nachricht-----
Von: UMN MapServer Users List [mailto:[EMAIL PROTECTED] Im
Auftrag von Stephen Woodbridge
Gesendet: Mittwoch, 30. Mai 2007 05:26
An: [email protected]
Betreff: Re: [UMN_MAPSERVER-USERS] turn layer labels on and off dynamically

Gregor Mosheh wrote:
I am using the Java MapScript for my application and I would like to present the option for the user to decide whether or not to show labels for a given layer. Is there any way to turn the label for a layer on or off dynamically? I didn't see anything obvious in the
MapScript API.
Speaking from the world of PHP/Mapscript, with hopes that it's applicable to your situation... Our solution is to set the label color to something invalid, to suppress the rendering of labels, e.g.:

   $class = $layer->getClassNyName('roads');
   if (!$labels) {
      $class->label->color->setRGB(-1,-1,-1);
   }




Ooops, that does not quite work the way you are expecting it to. color
-1 -1 -1 means transparent. so you are rendering the labels but they are
just transparent. Since you are rendering the labels, it takes cpu time and
it might bump other labels out of the cache. I don't think you really want
to do this.

A better solution might be to set the LABELMINSCALE or LABELMAXSCALE to a
value that would force the labels off, then reset the value to its normal
value to turn them back on based on the zoom scale.

You might also be able to use LABELREQUIRES "0" | "1" to turn on/off labels.

Both of these are LAYER attributes.

I have not played with either of these, but you should be able to get one of
them to work.

-Steve W.


Reply via email to