我正在尝试自定义mapbox中注释图层的外观。我想旋转每个注释图层。
- (RMMapLayer *)mapView:(RMMapView *)mapView layerForAnnotation:(RMAnnotation *)annotation
{
if (annotation.isUserLocationAnnotation)
return nil;
RMMarker *marker;
CGPoint xy = CGPointFromString(annotation.userInfo);
marker = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"arrow.png"]];
marker.transform = CATransform3DMakeRotation(atan2f(xy.x, xy.y) * 180 / M_PI,0,0,1);
marker.canShowCallout = YES;
return marker;
}
它在地图上首次加载时有效。但是当我移动或缩放地图时,它们会重置回其初始变换单位矩阵。
任何想法我该如何解决这个问题?还是地图框的错误?
看看RMMapView.m
annotationTransform
。这在指南针跟踪模式等移动过程中得到纠正,因此您需要使用自己的自定义转换来修改内容,因为这不是此 SDK 的公共 API 部分。