mstahv / v-leaflet

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

Clustering for feature-dense layers #41

Open jdryan1 opened 10 years ago

jdryan1 commented 10 years ago

I have point layers that can have upwards of tens of thousands of features, and would like to render these using clustering functionality. I notice there is a Leaflet.markercluster plug-in on the leafletjs.com/plugins page. Have you given any thought to wrapping this in v-leaflet? I'm willing to invest time and effort into this, but would appreciate any guidance and direction you might have. Thanks, John Ryan

mstahv commented 10 years ago

I have "seen this coming", but haven't done anything for it. So far, limiting points to visible viewport (and updating it dynamically in move end listener) has been enough for me.

I think at least GWT module should be separated, similarly as is done for the draw module. But, I guess the actual feature will be so popular that it might make sense to have it enabled by default in the actual Vaadin wrapper.

For Vaadin Wrapper it might be easy to build neat server side lazy loading quite easily.

willtemperley commented 10 years ago

I'd be happy to work on this - shouldn't be much work (famous last words). I guess we'd need a GWT module named g-leaflet-markercluster, then extend LeafletFeatureGroup connector to create a MarkerClusterGroup, inject the JS / CSS and the basics will be there.

Part of the reason I'd like to work on this is I'd like to better understand the dynamics between client-side caching and server-side state, as I've been noticing high bandwidth-usage when updating feature groups due to the entire state being re-sent to the client, instead of a "diff".

jdryan1 commented 10 years ago

I'm about a week away from being able to devote time to this, so if you can get started, great! Your approach is about what I had in mind. I would like to see the server-side LMarkerClusterGroup take a map for being able to pass the rich set of options that the MarkerClusterGroup.js supports. Lazy loading and client-server bandwidth requirements are also of high concern to me: I will need to support many tens of thousands of markers.

willtemperley commented 10 years ago

I've got the basics working for this.

GWT wrapper: https://github.com/willtemperley/g-leaflet-markercluster

Vaadin connectors: https://github.com/mstahv/v-leaflet/pull/43

It was necessary to add maxZoom to map options, as setting maxZoom is a requirement (otherwise markercluster throws an error). https://github.com/mstahv/g-leaflet/pull/5

willtemperley commented 10 years ago

New version with changes from matti & jdryan (thanks!) published:

https://vaadin.com/directory#addon/v-leaflet-markercluster-extensions