How can I specify a layer to not be in the cluster? - leaflet

I like about Leaflet.MarkerCluster that is changing the position of the markers if they are overlapping. I want the same thing, but with some markers to not be merged in a cluster. Any ideas?

There's Leaflet.LayerGroup.Collision, but that will hide markers completely when they overlap.
Keep in mind that Leaflet.MarkerCluster does not change the position of the markers. It simply creates a synthetic marker for clusters, with the median position of the cluster elements.

Related

leaflet markerclusterGroup layerGroup

I want to add circle and marker (with same latlng), but want to treat it as a one element in cluster.
Is it possible to do it?
L.layerGroup([L.marker(latnLng), L.circle(latnLng]);
Doesn't work.
It treats them as two elements.

Leaflet MarkerCluster stop auto re-clustering when zooming

When you zoom in and out, the markerclusters automatically "re-cluster", as in it calculates clustering again.
Is there an option for to disable the auto re-cluster when the zoom is changed?
Depending on exactly what you are trying to achieve, you might be interested in Leaflet.MarkerCluster.Freezable subplugin:
When frozen / disabled, clusters will no longer split / merge on map zoom, but retain their status as if they were on the specified zoom level.
For example if you want the clusters to reflect the zoom 15 configuration:
var map = L.map("map"),
mcg = L.markerClusterGroup(options);
mcg.addLayers(arrayOfMarkers);
mcg.addTo(map);
mcg.freezeAtZoom(15);
Disclaimer: I am the author of that subplugin.
Is there an option for to disable the auto re-cluster when the zoom is changed?
No.
In Leaflet.MarkerCluster, the cluster depends on the value of the maxClusterRadius option, which is measured in screen pixels at the current zoom level.
I encourage you to have a look at the other Leaflet plugins for clustering, as some of them have clustering algorithms which do not depend on the zoom level.

Leaflet: Force render a polyline for a marker outside of the bound

I am trying to render a network topology on a world map and I am using LeafletJS to render the world map.
I draw edges or connections between 2 end points using the polylines feature of LeafletJS. I am also using clustering to cluster large sets of markers. The issue I am facing is that as users drill down/ zoom into a cluster, some polylines vanish because the endPoint1 is connected to endPoint2 and endPoint2 is out of the map area hence the polyline is not drawn.
Any suggestions on how this can be achieved.

Limit leaflet cluster group expand depth

I am using cluster group. But how to limit cluster expand level. Suppose default cluster group loads with continent level then click. It expand to deeper level and when third time click on cluster group again it expand to country level. I want to fix three expand level of cluster group not below country level.
I tried freezeAtZoom() but it stops the cluster group from expand even from first level..
Your issue is still a little bit unclear.
Note first that when clicking on a cluster, it zooms to the extent of its child markers. This could represent a few zoom levels, depending on the actual child markers. It could even be directly the map's maximum zoom level, if all markers are really close one to each other. So there is no predefined target zoom level that the map will go to when you click, it all depends on the markers in that cluster.
Now if these markers do not change, and you can record the exact map's zoom level at which you want your clusters to no longer split apart on clicking, you have several ways to achieve that:
Define the map's maxZoom option to that zoom level, so that your users cannot go any deeper.
Add a map's "zoomend" event listener, so that if user goes deeper that your known zoom level, you freeze the cluster group to that recorded zoom. Remember that .freezeAtZoom(frozenZoom) can take an argument to specify at which zoom level the clusters should be frozen at, no matter the current zoom level.
Replace your individual markers by their equivalent cluster at your recorded zoom level ("country level"), maybe use Leaflet.markercluster singleMarkerMode option for styling, and iconCreateFunction option to override the counts and make them appear as if the clusters had many markers.

Multiple Annotations (IOS) Easiest way

Im using Annotations in IOS to display London Tube stations, but im looking at numbers and there are 280 or so.
Whats the easiest way to do this?
Individually or is there another option?
Cheers for all the advice
David
The performance is good with 280 annotations, the appearance is not. You have to group them into clusters when the user zooms out.
One way to do it is:
Decide how many cluster annotations you want to show.
Split the screen in x*y tiles so roughly x*y =~ numClusters and x/y=480/320=1.5
Add a cluster annotation per tile (it's a normal cluster with an array containing 0 or more annotations).
Run the k-means algorithm:
Iterate all annotations and add each one to the closest cluster.
Calculate a new center for each cluster, which will be an average of the centers of all its members.
Empty each cluster.
Repeat until no cluster moves any longer.
Remove empty clusters, if any.
You end up with numClusters clusters positioned according to the annotation density.
You can also leave a number of normal annotations on their own if they are away from the clusters. Depends on how you want it to look.