0

I'd like to have a check/uncheck option like this print checkbox to show/hide labels in my WMS layers served by mapserver 5.6.7 in openlayers 2.11. I have a toolbar where to put this using probably geoext1 or ext3.4, so the questions:

  1. Is this possible?
  2. If so, how can it be done?

I'd appreciate some support with this please, thanks!

Gery
  • 8,390
  • 3
  • 22
  • 39

1 Answers1

1

A workaround could be to use php-mapscript to open your mapserver mapfile, get the layer where you want to toggle label visibility, then you can act by deleting or insertin the "LABELITEM" object and/or loop over your classes and delete/insert the "LABEL" objects. You then have to save the modified mapfile... of course before doing all this you should have a backup of the original mapfile. All this is quite complex and not very elegant solution, but it might work.

another hack could be to have your labels in a different mapserver layer of type "ANNOTATION" and add/remove that layer from the "LAYERS" directive when querying the WMS!

Francesco
  • 47
  • 1
  • 7
  • thanks for that, sounds cool both options, but the 2nd one seems easier, could you elaborate a bit more that one please? – Gery May 08 '13 at 09:46
  • Well in your handler the function should modify your call to the mapserver URL string (e.g. ?SERVICE=WMS&VERSION=1.1.1&LAYERS=mylayer,mylayerLabels&REQUEST=GetMap&FORMAT=image/png&SRS=EPSG:32632&BBOX=51510,5051000,515500,5051500&WIDTH=400&HEIGHT=500) toggling the presence of "myLayerLabels" in the string – Francesco May 13 '13 at 18:21
  • how about the mapfile for ANNOTATION layer type? Any live demo? I think I can add some kind of toggle button with extjs for showing/hiding the labels, just should figure out how to link that to my WMS layer in openlayers – Gery May 13 '13 at 20:22