I’ve got an OpenLayersMap with several WMS Layers added setVisible(false).
OnClick they can be set to visible which works fine BUT if I try to set them invisible AGAIN nothing happens. I tried to repaint the layer, the map and even the splitpanel but nothing.
After adding the layers to the map I store them in a HashMap for easy access which could be part of the problem.
Update Implemented a work-around: Instead of changing the visbility I add and remove WMS layers from the map.
Problem is after adding 3 layers to the map 1 click generates 3 ClickEvents. Whereas if I add the 3 layers before adding the MapClickListener only 1 ClickEvent occurs.
Have you checked if the project page has issue reports about these issues? If not, please add them. That’s probably the best contribution you can do if you don’t dare to try fixing the bug by yourself. Also if you have a small code snippet that reproduces these issues, attach that to the ticket.
Couldn’t find my specific issue so I added a new one.
Also gained some more insight…
Every change I make to the map after the ClickListener was added results in one more ClickEvent per click.
Does not matter if I add or remove a layer. The source of the ClickEvent seems to be the same component (the map).
That brings me back to my initial approach (adjusting the visbility).
Unfortunately it shows no effect at all if I set the visbility of a layer to false :-/
I haven’t checked but it seems like the client side is just adding a new listener on each update. It should add it just once. I think this should be quite easy to fix. I can hint Özgün (the developer who added this specific feature) about the issue.
I ran into the same problems. After adding and removing popups within a layer, I get 3 click events instead of 1. Cleaning the registered listeners after each change does not help me out neither. Are there any fixes or workarounds in the meantime?