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);
   }



--
Gregor Mosheh / Greg Allensworth
System Administrator, HostGIS cartographic development & hosting services
http://www.HostGIS.com/

"Remember that no one cares if you can back up,
 only if you can restore." - AMANDA

Reply via email to