我正在使用以下代码进行 marker clustering
(用于生成带有桶的集群图标),使用 Google map sdk
,
id<GMUClusterIconGenerator> iconGenerator = [[GMUDefaultClusterIconGenerator alloc]initWithBuckets[@10,@50,@100,@500] backgroundImages[cluster1,cluster2,cluster3,cluster4]];
它正在正确地聚类标记,但它在 map 上显示 10+
或 50+
数字。例如,如果标记数为35
,则在 map 上显示10+
,当标记数超过50时,则显示50+
> 等(请参阅下面的截图)。我想在 map 上的集群图像上显示 确切数量的标记
!我的意思是如果标记的数量是 36
那么我想要 36
而不是 10+
。如果有人可以提供帮助!
截图:
我们可以通过改变 GMUDefaultClusterIconGenerator
类的一种方法来管理它。
在 GMUDefaultClusterIconGenerator.m
替换下面的方法,
- (UIImage *)iconForSizeNSUInteger)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];
}
与
- (UIImage *)iconForSizeNSUInteger)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];
}
我所做的是,我只是更改了 else 部分并将 text
设置为 exact number
而不是 string with +
!
关于ios - 如何在谷歌地图上显示聚集标记的确切数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41218459/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |