iphone - 在蓝色脉动点(用户当前位置)上显示航向,而不丢失精度圈

标签 iphone cllocationmanager compass-geolocation

我有一个 CLLocation 管理器,如下

myLocation = [[CLLocationManager alloc] init];
    myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
    myLocation.delegate=self;

如果设备支持航向信息,则调用方法来更新航向

if([CLLocationManager headingAvailable])
        [myLocation startUpdatingHeading];

标题的更改是通过以下方法检索的

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    [mymap setTransform:CGAffineTransformMakeRotation(-1 * newHeading.trueHeading * 3.14159 / 180)];

}   

我可以使用此信息(newHeading.trueHeading)来旋转 map 。但是,我如何在蓝点(用户当前位置的指示器)上显示一个以给定或强制精度描绘前进方向的扇区。我可以使用蓝点的自定义图像,但它会失去光“精度圈”。有什么方法可以获取蓝点 View 的引用并修改它,这样精度圆就不会丢失。

还可以通过负旋转来避免注释的旋转,但是本地图旋转时,注释的“标题”和“子标题”会扩展到可见屏幕的 View 之外。有什么办法可以将它们限制在 map View 中吗?

感谢您提前提供的帮助

最佳答案

您可以使用this project作为指导。它会旋转整个 map View ,但您可以将其推断到您的 View 。

编辑:如果您想自定义 userLocation 注释,则必须实现 viewForAnnotation 并检查给定注释是否为 MKUserLocation 并返回根据需要配置的自定义注释 View 。

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        //Configure your custom view to point to the current heading and return it.

    }

}

关于iphone - 在蓝色脉动点(用户当前位置)上显示航向,而不丢失精度圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7399641/

相关文章:

iphone - 如何从一个单元格导航到下一个 View ?

ios - Unity3D导出源: c++ header files not recognised

ios - 在 IOS 中获取错误的运营商名称

ios - 'locationManager(_:didUpdateLocations:)' 的参数具有与协议(protocol) 'CLLocationManagerDelegate' 预期不同的可选性

iphone - CLLocationManager保存缓存值

cllocationmanager - Swift 2 CLLocationManager更新错误

iphone - 使用指南针指向实际坐标位置而不仅仅是北

iphone - iOS 从备份恢复会保留 CoreData 应用程序数据吗?

android - 启用指南针 OSMDROID

android - 使用安卓手机测北