Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for custom cluster icon in Google Map Flutter #153092

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

Open
Mohit8G opened this issue Aug 8, 2024 · 20 comments
Open

Add support for custom cluster icon in Google Map Flutter #153092

Mohit8G opened this issue Aug 8, 2024 · 20 comments
Labels
c: new feature Nothing broken; request for a new capability p: maps Google Maps plugin P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team

Comments

@Mohit8G
Copy link

Mohit8G commented Aug 8, 2024

Use case

So Clustering in Google map is just landed but we don't have any support for custom cluster icon. There are some package on pub.dev but they are not proper solution to the problem.

Proposal

Need some properties that can override default cluster marker.
Like this
https://developers.google.com/maps/documentation/android-sdk/utility/marker-clustering

The ClusterManager constructor creates a DefaultClusterRenderer and a NonHierarchicalDistanceBasedAlgorithm. You can change the ClusterRenderer and the Algorithm using the setAlgorithm(Algorithm algorithm) and setRenderer(ClusterRenderer view) methods of ClusterManager.

You can implement ClusterRenderer to customize the rendering of the clusters. DefaultClusterRenderer provides a good base to start from. By subclassing DefaultClusterRenderer, you can override the defaults.

@darshankawar darshankawar added in triage Presently being triaged by the triage team c: new feature Nothing broken; request for a new capability p: maps Google Maps plugin package flutter/packages repository. See also p: labels. c: proposal A detailed proposal for a change to Flutter team-ecosystem Owned by Ecosystem team and removed in triage Presently being triaged by the triage team labels Aug 9, 2024
@stuartmorgan-g stuartmorgan-g removed the c: proposal A detailed proposal for a change to Flutter label Aug 9, 2024
@stuartmorgan-g
Copy link
Contributor

It looks like this is not going to be implementable without https://issuetracker.google.com/issues/140415468 (or, alternately, #150525), since the cluster renderer protocol requires a synchronous response. Usually when we have something that requires a synchronous response we pre-generated the necessary information, send it asynchronously, and store it on the platform thread for immediate response, but there's no way to pre-generate all possible images.

Even if clients didn't want the ability to change the icon dynamically (which they well might), they will almost certainly want to add a number, and that can be arbitrary as well.

@stuartmorgan-g
Copy link
Contributor

Please use a thumbs-up reaction on this comment specifically (in addition to the original feature request) if the following limited version of this feature would address your use case:

We could potentially implement an API that allowed pre-providing a map of {cluster count, image bitmap} cluster options, and have the cluster icon picked by finding the image in that map whose cluster count is the largest value that is <= the actual count. For instance, if someone provided {1: imageA, 10: imageB, 50: imageC, 100: imageD}, then any clusters of size 1-9 would use imageA, 10-49 would use imageB, 50-99 would use imageC, and anything larger would use imageD.

@stuartmorgan-g stuartmorgan-g added P3 Issues that are less important to the Flutter project triaged-ecosystem Triaged by Ecosystem team labels Aug 9, 2024
@Rishyash
Copy link

@stuartmorgan Needed one suggestion for this as I am not a native developer, what if I fork this package and add custom cluster logic for my usecase on native side code will this reflect on the flutter side map view?

@PauloAlves311
Copy link

I'm really happy that there is now official support for clustering, but the inability to alter the clusterOptions leaves it unusable in my opinion. Specially with custom map styles, the variety of colors makes it look really out of place. But let's be honest, green, red, blue, brown... Even without a custom map style, these colors look awful when put together, I can't believe any dev that cares about design would use these clusters as it is.

The clusterIcons also look too big in my personal opinion, so it would be nice to be able to adjust their scaling.

I am really not familiar with the limitations to implement this, but ideally there would be an example of the default renderer which would allow us to tweak all the details. As I can in js or with Fluster, but until then I really don't think I can use the official clustering.

@lucavenir

This comment was marked as off-topic.

@FeelHippo
Copy link

FeelHippo commented Oct 25, 2024

I agree that clustering without the possibility of customizing the appearance is not very useful. However, I spent a bit of time looking into a possible solution, and it's definitely something I might be able to fix.

I understand that the ClusterManager constructor here should probably extend setAlgorithm and setRenderer, and then trickle that down all the way back to the interface?

Not really my department, but I might give it a go. Or has @stuartmorgan been working on this?

@Shajk0
Copy link

Shajk0 commented Oct 26, 2024

When I read that flutter google maps offers its own clustering option, I immediately tried to implement it in my project, but when I realized that the cluster icons are not changeable and the numbers are fixed, it makes the whole thing completely unusable.
I would be happy if you create the possibility to make the cluster icons freely switchable just like the marker icons and also provide the possibility that the numbers are not displayed in these 10,50,100 groups but for example in the exact amount of the cluster

@Homerwatch

This comment was marked as off-topic.

@Homerwatch

This comment has been minimized.

@stefanvinteler

This comment has been minimized.

@mangeria
Copy link

Is it even possible to change the cluster default colors? Just implemented this on my app but the lack of customization options means I might have to look for another solutions.

@Mohit8G
Copy link
Author

Mohit8G commented Jan 31, 2025

Is it even possible to change the cluster default colors? Just implemented this on my app but the lack of customization options means I might have to look for another solutions.

For now no customization can be made.

@mangeria
Copy link

mangeria commented Jan 31, 2025

Is it even possible to change the cluster default colors? Just implemented this on my app but the lack of customization options means I might have to look for another solutions.

For now no customization can be made.

It would be beneficial to at least have things like:

  1. Cluster Nesting.
  • Cluster Zoom. Markers will cluster when the map is zoomed out beyond certain level. Currently I have to be zoomed all the way to world map for cluster market to appear in countries, markers inside cities are not clustered at all.
  • Cluster Grouping. Controls how close markers need to be to form a cluster. Unit could be radius?
  1. Custom Cluster Colors
  2. Custom Cluster Text

I'll keep following this issue. Thanks for consideration.

@servefast-cto

This comment has been minimized.

@niemsie
Copy link

niemsie commented Mar 27, 2025

Still no updates? It's been over half a year and no new features for the ClusterManager?

Besides marker customisation it would also be nice to be able to set a max zoom level at which clustering is disabled (e.g. if there are some pins that are just too close to each other).

@servefast-cto

This comment has been minimized.

@Homerwatch

This comment has been minimized.

@ivanpolish123

This comment has been minimized.

@andynvt

This comment has been minimized.

@Dzivo

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: new feature Nothing broken; request for a new capability p: maps Google Maps plugin P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team triaged-ecosystem Triaged by Ecosystem team
Projects
None yet
Development

No branches or pull requests