iOS MapBox - 在 imageForAnnotation 方法中获取注释标题

iOS MapBox - get annotation title in imageForAnnotation method

在下面的方法中:

- (MGLAnnotationImage *)mapView:(MGLMapView *)mapView imageForAnnotation:(id <MGLAnnotation>)annotation{

用于显示自定义注解UIImage,我希望能够区分我的注解(我可以有3种不同的类型)。

理想情况下,我希望能够在 MGLAnnotation 上有一个 tag 来轻松识别它是什么类型的注释,但我也可以使用标题、纬度和经度的组合来做所以。

但是在方法中,我无法得到annotation.coordinate,或者annotation.title

怎么会?我可以使此属性可访问吗?

您可以这样访问注释的坐标和标题:

NSString *title = [annotation title];
CLLocationCoordinate2D coordinate = [annotation coordinate];