开发者

To show heading direction on blue pulsating dot(user's current location) without loosing accuracy circle

I have a CLLocation manager as follows

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

if device supports heading information then method is called to update heading

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

and change in heading are retrieved from following method

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

}   

I can use this information (newHeading.trueHeading) to rotate the map. But how can I show a sector that will depict heading direction with given or forced accuracy, on blue dot (indicator of users current location). I am able to use custom image for blue dot but it looses light "accuracy circle" then. Is there any way to get a reference to the blue dot view and modify it, so that accuracy circle is not lost.

Also rotation of annotations can be avoided with negative rotation but when map is rotating the "Title" and "subTitle" of annotations gets extended beyond view of visible screen. Is there any way to limit them to map's view.

Thanks for any help in advance


You can use this project as a guide. It rotates the whole mapView, but you can extrapolate it to your view.

EDIT: If you want to customize the userLocation annotation you have to implement viewForAnnotation and check if the given annotation is MKUserLocation and return a custom annotationView configured as you want.

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

    }

}


    - (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)];


        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜