IOS swift 3/4 google map clustering show actual number of marker in cluster

IOS swift 3/4 google map clustering show actual number of marker in cluster

We can manage it by changing one method of GMUDefaultClusterIconGenerator class.

In GMUDefaultClusterIconGenerator.m replace below method,


(UIImage *)iconForSize:(NSUInteger)size {
NSUInteger bucketIndex = [self bucketIndexForSize:size];
NSString *text;

// If size is smaller to first bucket size, use the size as is otherwise round it down to the
// nearest bucket to limit the number of cluster icons we need to generate.
if (size < _buckets[0].unsignedLongValue) {
text = [NSString stringWithFormat:@"%ld", (unsigned long)size];
} else {
text = [NSString stringWithFormat:@"%ld+", _buckets[bucketIndex].unsignedLongValue];
}
if (_backgroundImages != nil) {
UIImage *image = _backgroundImages[bucketIndex];
return [self iconForText:text withBaseImage:image];
}
return [self iconForText:text withBucketIndex:bucketIndex];
}

with

(UIImage *)iconForSize:(NSUInteger)size {
NSUInteger bucketIndex = [self bucketIndexForSize:size];
NSString *text;

// If size is smaller to first bucket size, use the size as is otherwise round it down to the
// nearest bucket to limit the number of cluster icons we need to generate.
if (size < _buckets[0].unsignedLongValue) {
text = [NSString stringWithFormat:@"%ld", (unsigned long)size];
}


else{
text = [NSString stringWithFormat:@"%ld", (unsigned long)size];
}

if (_backgroundImages != nil) {
UIImage *image = _backgroundImages[bucketIndex];
return [self iconForText:text withBaseImage:image];
}
return [self iconForText:text withBucketIndex:bucketIndex];
}

What i have done is, I have just change else portion and set text as exact number instead of string with +!

Leave a Reply

Your email address will not be published. Required fields are marked *