Xamarin.Forms.GoogleMaps.Clustering icon indicating copy to clipboard operation
Xamarin.Forms.GoogleMaps.Clustering copied to clipboard

Toggling clustering during execution

Open mateuswolkmer opened this issue 5 years ago • 7 comments

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 avatar Jul 15 '19 13:07 mateuswolkmer

@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 avatar Jul 24 '19 19:07 mierzynskim

@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.

mateuswolkmer avatar Jul 26 '19 11:07 mateuswolkmer

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.

deepblueday avatar Sep 05 '19 13:09 deepblueday

This version should work with putting EnableBuckets > False https://github.com/mierzynskim/Xamarin.Forms.GoogleMaps.Clustering/pull/63

galadril avatar Feb 07 '20 12:02 galadril

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?

deepblueday avatar Feb 07 '20 12:02 deepblueday

hmmm let me see at runtime... i just read the first topic as having issues to set EnableBuckets > false..

galadril avatar Feb 07 '20 12:02 galadril

Want to turn clustering off at runtime + 1

ericc0504 avatar Feb 18 '20 10:02 ericc0504