Mapbox 注释图层旋转在地图缩放或移动时重置 [英] Mapbox annotation layer rotation resets on map zoom or move

查看:50
本文介绍了Mapbox 注释图层旋转在地图缩放或移动时重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 mapbox 中自定义注释图层的外观.我想旋转每个注释层.

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.

有什么想法可以解决这个问题吗?还是mapbox的bug?

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

推荐答案

查看 RMMapView.m 中的 annotationTransform.这会在诸如罗盘跟踪模式之类的移动过程中得到纠正,因此您需要使用自己的自定义转换来修改内容,因为这不是此 SDK 的公共 API 部分.

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.

这篇关于Mapbox 注释图层旋转在地图缩放或移动时重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆