I am using Route-Me: Alpstein fork for developing an iOS app. The original Route-Me/Mapbox code had an option to customize the cluster icon and also the the cluster count. I've been looking for a way to do this with the Route-Me: Alpstein fork.
Something similar to this:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation)
return nil;
RMMapLayer *layer = nil;
if (annotation.isClusterAnnotation)
{
layer = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"circle.png"]];
layer.opacity = 0.75;
layer.bounds = CGRectMake(0, 0, 75, 75);
[(RMMarker *)layer setTextForegroundColor:[UIColor whiteColor]];
[(RMMarker *)layer changeLabelUsingText:[NSString stringWithFormat:@"%i", [annotation.clusteredAnnotations count]]];
}
else
{
layer = [[RMMarker alloc] initWithMapboxMarkerImage];
}
return layer;
}
I cannot see 'isClusterAnnotation' defined anywhere in the source. How can I achieve the same results using the Route-Me: Alpstein fork? Any help would be greatly appreciated.
In my project I used the following, inside the mapView:layerForAnnotation:
method of the map delegate:
if ([annotation.annotationType isEqualToString:@"RMClusterAnnotation"]) {
UIImage *clusterImage = [UIImage imageNamed:@"foo.png"];
RMMarker *newMarker = [[RMMarker alloc] initWithUIImage:clusterImage];
// this is how I managed to count the annotations inside a cluster
NSInteger annotationsInCluster = [((RMQuadTreeNode *)annotation.userInfo).annotations count];
// you can add a label to the annotation with the number of clustered annotations
[newMarker changeLabelUsingText: [NSString stringWithFormat:@"%i", annotationsInCluster]];
return newMarker;
}
Hope this works for you!