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
Utilize leaflet layering #13
Comments
This might be a bit hard as a MarkerClusterGroup is a FeatureGroup. |
Is there no way to make cluster layers then as opposed to the leaflet layering? As in we can add the markers to the clusterer in groups, which then adds a button to the map, or is that what you mean isn't possible? |
Not currently. I may have to tackle this for our own internal purposes, so I may build it yet. |
I agree this would be cool. Maybe if I dig into the Leaflet documentation I can take a stab at this... |
How is the progress going in this area? I found myself in need of this exact functionality and i'm afraid my skillset is not up to par with the scope of this problem. So is there any plans, within a near future, to attack this problem or should I head for a different solution? |
I just posted a gist that gives an example of how to have markers in multiple layers, and how to toggle layers and add/remove markers: https://gist.github.com/alexcwatt/5412222 The basic strategy is having arrays ("layers") of markers. Markers can be in multiple layers. When the user toggles layer visibility, all markers are removed, and then all the ones that are still in the layers that are visible are added back. |
Sounds great, do you have a demo for this functionality? |
@pvhee I just put one together here: http://jsfiddle.net/pvwKJ/4/ I also realized that I left the definition for the |
@pvhee @alexcwatt I'm extremely interested in this. Any clue on how I can use the clusters and layers? This doesn't work: http://jsfiddle.net/pvwKJ/4/ |
I thought I'd written up a work around on here, but there isn't :-/ so here is the idea: Create an empty LayerGroup for each of your groups of markers you want in the cluster control. Add these empty groups to the layers control. Listen to overlayadd and overlayremove events on the map, these will tell you when those layers are ticked/unticked. And that should do it :-) |
Hi @danzel,
Hope you can help me. |
Is |
@danzel, Apparently while if I use .id, it always gets into the ol.layer.id == layerUS.id... |
comment by adrift http://jsfiddle.net/pvwKJ/4/ would not work. XXXXX is either ('overlayadd', 'overlayremove') Doing all clear layers then add would simply yield trouble. because of troublesome situation of not having exact access to markers_visible because of only having access to one context e.target -- one layer. Currently trying to figure out cluster object aka markers are just lumped sequentially and not grouped at all. |
@chriscalip It should be working again now: http://jsfiddle.net/pvwKJ/7/ I Please let me know if it works for you or if there's another issue (not |
@alexcwatt nice one. that example of yours works. too bad its making use of bootstrap.js and bypass leaflet.js map.on functionality to bring about this feature. Still with the exigencies of the situation l might also have to go with your technique. Also what I meant above is that leaflet.js map.on hook . on events overlayadd and overlayremove you only have access to the layer "added" or "removed" To illustrate point right now the suggested workaround is to listen in map.on events then do a clearLayers and addLayers appropriately. on hook map.on context "a" is not directly tied to the storage arrays of markers_category..
map.on('overlayremove', function(a) {
cluster.clearLayers();
cluster.addLayers(markers_category[1]);
});
** EDIT ** I have pulled off what danzel mentioned "Listen to overlayadd and overlayremove events on the map, these will tell you when those layers are ticked/unticked. After the work day. I'll scrub and do a jsfiddle for illustration purposes. |
@chriscalip If you come up with anything better, I'd appreciate if you post |
@alexcwatt for sure, here's an illustrative link on what danzel mentioned. |
Is there an example with mapbox layers used? I publish a lot with mapbox and it would be great to have a snippet of code to handle layer toggling. |
This is implemented in a plugin now |
Not sure if anyone is still on this, however I have fixed the fiddle example from above using multiple layers for marker cluster. I am now looking into using the sub-plugins. |
It would be fantastic if the marker clusterer supported layers like the stock leaflet layer functionality so users can enable/disable layers of markers and have the clusters update accordingly.
The text was updated successfully, but these errors were encountered: