Skip to content
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

Items not "declustered" (broken into smaller items) after map zooms in #443

Closed
vanjabobotic opened this issue Mar 1, 2018 · 8 comments
Closed

Comments

@vanjabobotic
Copy link

Summary:

When you zoom in, some items stays in cluster, no matter how close you zoom in.

Steps to reproduce:

Unfortunately, I'm not sure. It happens all the time, but only for some locations.

Expected behavior:

I'm expecting to see the "broken" clusters when the map is zoomed in.

Observed behavior:

Instead, the items are clustered all the time, whether you click on the cluster on zoom in.

Device and Android version:

It happens on any Android device with any Android I've tried (>5.0), the stock version ROM from the manufacturer.

Screenshots:

screenshot_20180209-143302
2018_03_01_15_23_16.mp4.zip

@real-artswan
Copy link

real-artswan commented Mar 6, 2018

Got the same problem with web page. Some clusters work correctly, but some don't and don't break down when zooming.
image

@marandaneto
Copy link

did you try changing the code below?

@Override protected boolean shouldRenderAsCluster(Cluster cluster) { return cluster.getSize() > 2; }

if the pins are so close, it's natural that they will keep as a cluster since would be a mess to understand them

@real-artswan
Copy link

I can say that in my case pins are not close at all, in fact there are no any pin closer than few tens kilometers around the marker on my screenshot. My pins are real house addresses.

@Gaetano-Dati
Copy link

Has this problem been solved in some way?

@emadimehrdad
Copy link

When pins are so close and the map zoomed in high level, pins don't uncluster.how to fix this problem?

@gusthavosouza
Copy link

gusthavosouza commented Aug 26, 2019

Hi guys!
I had solved this problem in two ways:
First One just set setMinClusterSize(1); // however if your lat and long are exactly the same or very close sometimes a cluster will be showed.

Second one:

implements OnCameraMoveListener on your CustomRenderer or implements it in your activity and set the maxZoomLevel in your CustomClusterRenderer doing it you avoid to keep a referecen for the Map.
Create a float variable to save the max zoom level which google maps can work with in this case the constructor do the job.

public class CustomClusterRenderer extends DefaultClusterRenderer<MapMarker> implements GoogleMap.OnCameraMoveListener { 

    private final float maxZoomLevel;
    private final float zoomOffset = 5f;

    public CustomClusterRenderer(Context context, GoogleMap map, ClusterManager<MapMarker> clusterManager) {
        super(context, map, clusterManager);
        this.mMap = map; // you don't need to keep this reference if you dont need
        this.maxZoomLevel = mMap.getMaxZoomLevel() - zoomOffset;
      }
}

I just get the current zoom level.

 @Override
    public void onCameraMove() {
        currentZoom = mMap.getCameraPosition().zoom;
    }

Finally the method shouldRenderAsCluster


@Override
    protected boolean shouldRenderAsCluster(Cluster<MapMarker> cluster) {
        boolean wouldCluster = super.shouldRenderAsCluster(cluster);

        //determine if you still want it based on ZoomLevel
        if (wouldCluster) {
            wouldCluster = currentZoom < maxZoomLevel;
        }

        return wouldCluster;
    }

@stale
Copy link

stale bot commented Oct 3, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. label Oct 3, 2019
@jpoehnelt jpoehnelt removed the status: will not fix Invalid (untrue/unsound/erroneous), inconsistent with product, not on roadmap. label Oct 3, 2019
@barbeau
Copy link
Collaborator

barbeau commented Nov 13, 2019

Looks like @gusthavosouza solved this in his comment above - #443 (comment).

If this solution doesn't work for anyone please re-open this issue. Thanks!

@barbeau barbeau closed this as completed Nov 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants