【问题标题】:To show heading direction on blue pulsating dot(user's current location) without loosing accuracy circle在蓝色脉冲点(用户当前位置)上显示航向而不丢失精度圈
【发布时间】:2011-09-13 09:31:03
【问题描述】:

我有一个如下的 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) 来旋转地图。但是我如何才能在蓝点(用户当前位置的指示器)上显示一个以给定或强制精度描绘航向方向的扇区。我可以将自定义图像用于蓝点,但它会失去轻微的“精度圈”。有什么办法可以参考蓝点视图并对其进行修改,使精度圈不丢失。

也可以通过负旋转来避免注释的旋转,但是当地图旋转时,注释的“标题”和“子标题”会超出可见屏幕的视野。有没有办法将它们限制在地图的视图中。

提前感谢您的帮助

【问题讨论】:

    标签: iphone cllocationmanager compass-geolocation


    【解决方案1】:

    您可以使用this project 作为指导。它会旋转整个 mapView,但您可以将其外推到您的视图中。

    编辑:如果你想自定义 userLocation 注释,你必须实现 viewForAnnotation 并检查给定的注释是否为 MKUserLocation 并返回一个自定义的 annotationView 配置为你想要的。

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

    【讨论】:

    • 我可以根据从 newlocation.trueheading 获得的值旋转地图,但我仍然无法修改蓝点(用户当前位置)以显示用户标题。我已编辑问题以显示我所做的更改。
    【解决方案2】:
        - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
            if (newHeading.headingAccuracy > 0) {
                    // [newHeading retain];
                 float heading = newHeading.trueHeading >= 0 ? newHeading.trueHeading : newHeading.magneticHeading;
    
    
                 [mymap setTransform:CGAffineTransformMakeRotation(heading)];
    
    
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多