ios - map 框标注

标签 ios mapbox

我想用不同的图像创建多个注释。要创建注释,在 viewDidLoad 中:

for (int i=0; i<[annotationsArray count]; i++) {
    RMAnnotation *annotation = [[RMAnnotation alloc]
                                initWithMapView:mapView
                                coordinate:CLLocationCoordinate2DMake([[latitudeArray objectAtIndex:i] doubleValue], [[longitudeArray objectAtIndex:i] doubleValue])
                                andTitle:[nameArray objectAtIndex:i]];
    [self.mapView addAnnotation:annotation];

}

在下面的方法中,它为每个注释提供相同的图像:

- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
    if (annotation.isUserLocationAnnotation) {
        return nil;
    }
    RMMarker *marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"CoffeeShopsIcon.png"]];

    marker.canShowCallout = YES;

    marker.leftCalloutAccessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CoffeeShopsIcon.png"]];

    marker.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    return marker;
}

我有一个包含图像名称的数组。我怎样才能解决这个问题?

最佳答案

您想使用 -[RMAnnotation userInfo] API。

/** Storage for arbitrary data. */
@property (nonatomic, strong) id userInfo;

关于ios - map 框标注,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25367654/

相关文章:

javascript - Mapbox 切换多层的可见性

ios - 在离线 iOS 应用程序中使用 MBTiles

iphone - 如何在 iPad 中自动旋转期间重新排列 View

ios - 如何在 iOS 中将 BundleVersion 更改为四个非负整数

ios - Swift - 使用 IB 的文本字段的自定义 inputView?

leaflet - 如何为传单下载 map 图 block ?

javascript - 如何过滤列表中的内容到 map 框

ios - 提交 Crashlytics : Unable to submit build - iOS app Jenkins

ios - 当连接到特定 wifi : ios 时运行我的应用程序

jupyter-notebook - Jupyter 中的 Mapbox map 未显示