Xamarin.Forms.GoogleMaps.Clustering
Xamarin.Forms.GoogleMaps.Clustering copied to clipboard
Toggling clustering during execution
So I have a switch where users can enable or disable the map clustering. When enabled, buckets should show up when the map is zoomed out (default and working behavior), and when disabled, no clustering should occur when zoomed out (buckets should be disabled).
I don't seem to be able to disable the buckets after the map has been initialized. Simply setting mapView.ClusterOptions.EnableBuckets
to false
doesn't work and there are not other options to disable the clustering. Should I re-render the map after disabling buckets, and if so, how should I do it? What is the best way to enable toggling between clustering and not clustering the map during app use?
This is my map initialization:
mapView.UiSettings.ZoomControlsEnabled = false;
mapView.UiSettings.CompassEnabled = false;
mapView.UiSettings.MapToolbarEnabled = false;
mapView.UiSettings.TiltGesturesEnabled = false;
mapView.UiSettings.RotateGesturesEnabled = false;
if (AppStatusUtil.Current.HasLocationPerm)
{
mapView.MyLocationEnabled = true;
mapView.UiSettings.MyLocationButtonEnabled = true;
}
mapView.PinClicked += OnPinClick;
mapView.MapClicked += OnMapClick;
mapView.ClusterOptions.Algorithm = ClusterAlgorithm.NonHierarchicalDistanceBased;
mapView.ClusterOptions.SetBuckets(ColorUtil.ClusteringBucketColors);
@mateuswolkmer I don't think it's not currently supported but I think it should be possible to implement it. Performance is my only concern. Re-rendering a whole map could be required and it can cause a nasty lag. How many pins do you have in your map?
@mierzynskim Currently 341, but it is going to be 1000+ soon. Yes it is going to be laggy but I want to give users the option anyhow. Not a priority though.
I am also facing a scenario where turning clustering on/off would be useful. +1 to this feature request.
I'd rather have the choice (even if performance is not great) than not.
This version should work with putting EnableBuckets > False https://github.com/mierzynskim/Xamarin.Forms.GoogleMaps.Clustering/pull/63
Let me see if i get it right. So...now we have a property to enable/disable clustering at runtime? Is this in the "official" nuget? Any chance you could provide a code example of how to use?
hmmm let me see at runtime... i just read the first topic as having issues to set EnableBuckets > false..
Want to turn clustering off at runtime + 1