-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate Layers on the LayersControl. #135
Comments
Hi Mario, That looks to me that it doesn't seam to accommodate more room for the Layers control once it has already been shown with a bit shorter layer list. I'm not 100% sure but I'd suspect this is an issue in underlaying Leaflet JS. You could try repeating the issue with plain LeafletJS and report the issue there. Alternatively, you could take another approach to layer selection, which I have found out to work pretty well. It is pretty easy to use core Vaadin UI components to build a layer selection as well, e.g. using option group or Table. You can then place the selector UI where ever you want but you can of course still put it e.g. on top of the LMap component using AbsoluteLayout. cheers, |
Thanks @mstahv ... For now, we are implementing the layer selector using another component (ComboBox), as you say, this is a good approach. I'll try to reproduce the issue using Leaflet JS library, for check if this issue are on the JS library. Thanks again. PD. any information that i find, i´ll post it here. |
I just upgraded to 1.0.0 and I have the same issue. When create the LMap I add baseLayers like this: Then later when adding other wms layers the base layer duplicte somehow. In the earlier version we dis this (remove layer from controly and lmap) Now I can do only this: but I still have the issue with the base layers Thanks |
Could somebody add a reduced test case (here or a preferably as a pull request to projects tests)? |
@mstahv Yes. I'll try to add a very simple test case today or tomorrow. Thanks |
Sorry about my crappy code. But this simple example shows the problem (just copy it into a UI or View)
-> By just adding or removing layers the base layers get duplicated I'm not sure weather this is a leaflet issue or a v-leaflet issue.
|
I can confirm I've experienced the same problem in the past too. |
Nice way to run tests with UIRunner. I added a test case to easily check this issue. |
Hi again :). I tested the Leaflet JS adding layers on-demand (base layer and overlay layer), and the layer control don't duplicate the list of layer. Here the example. After click on the buttons, this es result. Regards. |
I think I found the bug. Debugging with chrome developer tools and setting breakpoints in all addOverlay() methods I actually tracked it down to this method in Java code: LeafletLayersConnector.doStateChange(StateChangeEvent stateChangeEvent) {...} I think this method calls addBaseLayer() and addOverlay() for each existing baseLayer and overlay which results in duplicates. Can you verify this? |
The solution i see is to only add layers (with addBaseLayer() and addOverlay()) when they are not already added. I'm not that deep into vaadin clientside development. I tried to enhance the LayerControlInfo.java with a boolen value 'added' and then in LeafletLayersConnector.doStateChange() only add the layer when it's state is !added, and then set added = true. Somehow the state change (added = true) is not propagated back and it doesn't work. Another solution I found is to always remove the layer before adding. Just call 'getControl().removeLayer(layerConnector.getLayer());' before adding the layer. This removes all layers from the control and then adds all layers to the control. This worked with my test case. |
Thanks dudes, will cut a release soon! |
Hi @mstahv
Firstly, thanks for your great job with the add-on.
I'm having a little problem using the add-on.
I'm creating and adding a list of LWmsLayer on the map using the addOverLay method on the init() of my UI class, all the layers are loaded correctly.
But, i added a button to create and add a choropleth layer on the map after init load, the problem are present when i click the button:
On the server side, the LayersControl have the list with the correct number of layers.
On the client side, when i display the layer contro, when i do this, the list of layer on the LayersControl on the client side duplicate the records of layers.
How can i prevent this issue?
The text was updated successfully, but these errors were encountered: