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

Cluster with markers in same location take default design #655

Closed
beli63 opened this issue Mar 10, 2020 · 13 comments
Closed

Cluster with markers in same location take default design #655

beli63 opened this issue Mar 10, 2020 · 13 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@beli63
Copy link

beli63 commented Mar 10, 2020

Hello,

I've update the library from 0.6.2 to 1.0.0 and I have a trouble with Cluster (Bug is not present in version 0.6.2)
I have Custom Cluster
When I have markers in same location, the Cluster take the default design and not mine

Screenshot_1583853766
Screenshot_1583853778

@beli63 beli63 added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 10, 2020
@barbeau
Copy link
Collaborator

barbeau commented Mar 10, 2020

@beli63 Thanks for reporting this. Are you able to share code you used to create the above screenshot?

@beli63
Copy link
Author

beli63 commented Mar 11, 2020

@barbeau , I use CustomMarkerClusteringDemoActivity Demo's code.
I just put same location in 2 Markers

@barbeau barbeau added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels Mar 11, 2020
@barbeau
Copy link
Collaborator

barbeau commented Mar 11, 2020

@beli63 Ok, thanks for the additional info. This may also be related to #384.

@beli63
Copy link
Author

beli63 commented Mar 11, 2020

@barbeau Okay thanks

@nicemak
Copy link

nicemak commented Mar 20, 2020

still facing this bug in 1.0.2, any update?

@barbeau
Copy link
Collaborator

barbeau commented Mar 20, 2020

Sorry, no update yet!

@josh9060
Copy link

josh9060 commented Mar 20, 2020

I am also encountering this bug. By changing the algorithm to GridBasedAlgorithm it stops the default clustering icon from being shown. However, this introduces other problems.

I am not sure if there is anything erroneous is occurring with the algorithms... hope that helps!

@B3nedikt
Copy link

A temporary fix would be to just overwrite "onClusterUpdated" with an empty implementation. Seems to fix the issue for me.

@androidovshchik
Copy link

@B3nedikt thanks. Fixed this problem

@beli63
Copy link
Author

beli63 commented Mar 31, 2020

@B3nedikt Yes I valid, it fixed the problem
Thanks

@barbeau
Copy link
Collaborator

barbeau commented Apr 2, 2020

Looking at the code, it looks like this behavior is new in v1.0 due to a side-effect of PR #627, part of which fixes an issue with existing markers not reflecting updated contents. For example, as discussed in #90, prior to #627 if you updated a marker's position, title, or snippet, that update wouldn't be reflected on the map.

PR #627 fixes this by updating the cached cluster marker using a new protected method onClusterUpdated(), whose default implementation uses the default design. So, when iterating through the markers to render them the 2nd identical location triggers onClusterUpdated() instead of onBeforeClusterRendered(), which then updates the marker with the default cluster design.

So, to fix this, you should override onClusterUpdated() as @B3nedikt suggested above, but the implementation should be the same as your onBeforeClusterRendered() implementation to avoid any caching issues.

Similarly, you should override the implementation of onClusterItemUpdated() with the same implementation as onBeforeClusterItemRendered().

An aside - the implementation can't be identical because you're working with a Marker instead of MarkerOptions, but it's as simple as changing from the format of markerOptions.title("X") to marker.setTitle("X"))

Please give that a shot and see if it works!

barbeau added a commit that referenced this issue Apr 2, 2020
See #655 (comment) - we need to update the custom clustering demo for the best practices surrounding marker caching, following the implementation of #627 in v1.

This means overriding onClusterUpdated() and onClusterItemUpdated() with the same implementations as onBeforeClusterRendered() and onBeforeClusterItemRendered(), respectively.
@barbeau
Copy link
Collaborator

barbeau commented Apr 2, 2020

FYI, I've opened a pull request at #679 which shows the changes discussed above for the CustomMarkerClusteringDemoActivity in the demo app.

barbeau added a commit that referenced this issue Apr 8, 2020
See #655 (comment) - we need to update the custom clustering demo for the best practices surrounding marker caching, following the implementation of #627 in v1.

This means overriding onClusterUpdated() and onClusterItemUpdated() with the same implementations as onBeforeClusterRendered() and onBeforeClusterItemRendered(), respectively.
@barbeau
Copy link
Collaborator

barbeau commented Sep 20, 2021

Closed by #679

@barbeau barbeau closed this as completed Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants