mstahv / v-leaflet

Leaflet add-on for Vaadin
Other
43 stars 38 forks source link

Layers ordering does not work. #47

Open AllaV opened 10 years ago

AllaV commented 10 years ago

Leaflet layers reordering does not work.

mstahv commented 10 years ago

Test case for the issue: https://github.com/mstahv/v-leaflet/commit/ee3dfd4188e739a123232c7d45d318c76f59343b

mstahv commented 10 years ago

Hi,

I worked a bit on this and thanks to it I spotted also another, possibly even worse issue when using layergroups: moving a path into another group makes the path vanish altogether.

I fixed that, but not this one. This one will have to wait for some larger refactoring related to how sub components and their drawing is handled. That's bit hacky ATM as Vaadin 7 has some design "decisions" that make client side rendering indeterministic...

So the "official" workarounds at this point:

  1. Always recreate groups, as in this example. Performance wise this is actually in par with reordering.
  2. Use FeatureGroups and their bringToFront() / bringToBack methods to do reordering. This is the most efficient solution. LLayerGroup also has the methods due to inheritance, but they don't support them in Leaflet.
AllaV commented 10 years ago

Hi Matti,

I didn't manage to get workaround 2 working. Layers remained unchanged. But we can live for a while with workaround 1, I hope.

I've seen you enabled popups. But I don't understand how to use them on LMap. Please advice.

Thank you, Alla

From: Matti Tahvonen [mailto:notifications@github.com] Sent: Saturday, March 22, 2014 5:52 PM To: mstahv/v-leaflet Cc: Alla Volkov Subject: Re: [v-leaflet] Layers ordering does not work. (#47)

Hi,

I worked a bit on this and thanks to it I spotted also another, possibly even worse issue when using layergroups: moving a path into another group makes the path vanish altogether.

I fixed that, but not this one. This one will have to wait for some larger refactoring related to how sub components and their drawing is handled. That's bit hacky ATM as Vaadin 7 has some design "decisions" that make client side rendering indeterministic...

So the "official" workarounds at this point:

  1. Always recreate groups, as in this example<https://github.com/mstahv/v-leaflet/blob/master/src/test/java/org/vaadin/addon/leaflet/demoandtestapp/ComponentsToNewLayerGroupOrdering.java>. Performance wise this is actually in par with reordering.
  2. Use FeatureGroups and their bringToFront() / bringToBack methods to do reordering. This is the most efficient solution. LLayerGroup also has the methods due to inheritance, but they don't support them in Leaflet.

— Reply to this email directly or view it on GitHubhttps://github.com/mstahv/v-leaflet/issues/47#issuecomment-38355037.

mstahv commented 10 years ago

You must use FeatureGroups instead of LayerGroup to make bringToFront() work.

Popup test case/usage example: https://github.com/mstahv/v-leaflet/blob/master/src/test/java/org/vaadin/addon/leaflet/demoandtestapp/PopupTest.java