Mapbox annotation layer rotation resets on map zoom or move

喜欢而已 提交于 2019-12-24 11:36:59

问题


I'm trying to customize the appearance of the layers of my annotations in mapbox. I want to rotate every annotation layer.

- (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;
}

It works the first time they load on the map. But when I move or zoom the map they reset back to their initial transform identity matrix.

Any ideas how I could solve this ? Or is it a bug of mapbox ?


回答1:


Take a look in RMMapView.m at the annotationTransform. This gets corrected during movements for things like compass tracking mode, so you'll want to modify things with your own custom transform(s) as this isn't a public API part of this SDK.



来源:https://stackoverflow.com/questions/21754379/mapbox-annotation-layer-rotation-resets-on-map-zoom-or-move

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!