bpillon / google_maps_cluster_manager

Simple Flutter clustering library for Google Maps
https://pub.dev/packages/google_maps_cluster_manager
MIT License
119 stars 94 forks source link

How can I add a label for each individual marker? #16

Closed devfelipereis closed 3 years ago

devfelipereis commented 3 years ago

I see that I can add a label for a cluster but I can not figure out how to add a label for each marker on the map.

bpillon commented 3 years ago

Hello. I think I don't understand your question as clusters and individual markers are handled the same way (individual markers are considered as single item cluster).

omchiii commented 3 years ago

Future<gm.Marker> Function(Cluster<Place>) get _markerBuilder => (cluster) async { return gm.Marker( markerId: gm.MarkerId(cluster.getId()), position: cluster.location, onTap: () { print('---- $cluster'); cluster.items.forEach((p) => print(p)); }, icon: await _getMarkerBitmap(cluster.isMultiple ? 125 : 75, text: cluster.isMultiple ? cluster.count.toString() : cluster.items.first.availableChargers), ); };

@devfelipereis I think I understand your question. If the cluster.isMultiple is false, that means that cluster.items only has one item. So you would use cluster.items.first."data you want".