自定义标注(mapBox iOS sdk)
我想创建具有自定义视图的详图索引-例如此视图自定义标注(mapBox iOS sdk),ios,objective-c,mapbox,Ios,Objective C,Mapbox,我想创建具有自定义视图的详图索引-例如此视图 (来源:) 但我找不到任何解决办法来做这件事,我找到的唯一解决办法是使用以下代码: - (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation ... marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"marker
(来源:) 但我找不到任何解决办法来做这件事,我找到的唯一解决办法是使用以下代码:
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
...
marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"marker.png"]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
CalloutViewController* callout = [storyboard instantiateViewControllerWithIdentifier:@"callout"];
[marker setLabel:callout.view];
}
但结果并不是我想要的,因为当我设置标记的label属性时,视图会在不点击标记的情况下显示
你知道怎么解决这个问题吗?或者可能有其他方法来实现这一点
编辑:
我也在上找到了这篇文章,但我不知道如何实现它。请看
它告诉您,如果标记的图层具有canShowCallout==YES
和title!=无
在其上设置
如果您的标记满足此要求,您将获得与MapKit相同的标注:)
设置contentView或left-或right-callout视图变量以修改该详图索引视图
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
...
marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"marker.png"]];
[marker setCanShowCallout:YES];
[marker setTitle"Test"];
//Following only works with iNimas version
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
CalloutViewController* callout = [storyboard instantiateViewControllerWithIdentifier:@"callout"];
[marker setContentView:callout.view];
return marker ;
}
这超出了SDK的范围,因为它是在依赖于
SMCalloutView
的项目中完成的。由于两者都是开源的,您可以添加此行为,但目前不可能
(我编写了有问题的SDK) 注意:contentView仅在iNima版本的sdk中可用!原始SDK仅支持标题、leftCalloutAccessoryView和RightCalloutAccessoryViewsCallout已经有了一个可以正常工作的contentView属性。甚至有一个公关杰出的补充这一点