I created a map with several layer groups - these layergroupd should be used to filter different kind of content shown on my map.
The clustering of the GeoPoints works fine - but if i click on a layer in layer control it shows me all the points without clustering..

Attached you find a screenshot explaining the behavior.

SteffenR

Comments

steffenr’s picture

I just read through the issues on the github page - seems to be complicated issue - maybe some has tried it before and found a working solution..
I'm using leaflet_views_data to build up my map and its layers.
https://github.com/Leaflet/Leaflet.markercluster/issues/13

SteffenR

rdeboer’s picture

Status: Active » Postponed (maintainer needs more info)
steffenr’s picture

Maybe i just found a working solution provided in the comments at github.
http://jsfiddle.net/pvwKJ/4/

Unfortunately i don't have the time to integrate these changes into the module - i hope to get it fixed in the next week and provide a patch in here..

SteffenR

davidhk’s picture

Issue summary: View changes
StatusFileSize
new10.75 KB

The issue 13 mentioned above, https://github.com/Leaflet/Leaflet.markercluster/issues/13, has been updated to say that support for clustering in the layer switcher is now supported by sub-plugins.

If we load the sub-plugin in leaflet.featuregroup.subgroup-src.js, then with edits to 4 lines of leaflet_markercluster.drupal.js, we can add clustering support to groups of points. (Modified copy of leaflet_markercluster.drupal.js attached, see lines 122-3, 145, 155.)

The reason I'd like this support is to have the markers show as a layer in the layer switcher that the user can toggle on & off. So if instead of passing an array of points, $points, to leaflet_render_map(), I create a group and pass that in I get the desired behaviour. The group is simple to make:

  $group_of_points[] = array(
    'group' => true,
    'features' => $points,
    'label' => 'Markers',
  );

You can see the result if you visit http://gwulo.com/map-of-places and toggle the 'Markers' layer.

Would this be a useful addition to the module?