2016-07-13 1 views

答えて

1

これは、その方向に移動するためのものです それはあなたのために役立つかもしれないとピンの角度であなたはipadの方向になるでしょう。

-(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { 
    // Use the true heading if it is valid. 
    CLLocationDirection direction = newHeading.magneticHeading; 
    CGFloat radians = -direction/180.0 * M_PI; 

    self.strAccuracy = [NSString stringWithFormat:@"%.1fmi",newHeading.headingAccuracy];  
    [lblAccuracy setText:self.strAccuracy]; 

    //Rotate Bearing View 
    [self rotateBearingView:bearingView radians:radians]; 

    //For Rotate Niddle 
    CGFloat angle = RadiansToDegrees(radians); 
    [self setLatLonForDistanceAndAngle]; 
    [self rotateArrowView:arrowView degrees:(angle + fltAngle)]; 
} 

-(void)rotateArrowView:(UIView *)view degrees:(CGFloat)degrees 
{ 
    CGAffineTransform transform = CGAffineTransformMakeRotation(DegreesToRadians(degrees)); 
    view.transform = transform; 
} 

-(void)setLatLonForDistanceAndAngle 
{ 
    dblLat1 = DegreesToRadians(appDelegate.dblLatitude); 
    dblLon1 = DegreesToRadians(appDelegate.dblLongitude); 

    dblLat2 = DegreesToRadians(objClsProductSearch.dblLatitude); 
    dblLon2 = DegreesToRadians(objClsProductSearch.dblLongitude); 

    fltLat = dblLat2 - dblLat1; 
    fltLon = dblLon2 - dblLon1; 
} 

-(float)getAngleFromLatLon 
{ 
    //Calculate angle between two points taken from http://www.movable-type.co.uk/scripts /latlong.html 
    double y = sin(fltLon) * cos(dblLat2); 
    double x = cos(dblLat1) * sin(dblLat2) - sin(dblLat1) * cos(dblLat2) * cos(dblLon2); 
    CGFloat angle = RadiansToDegrees(atan2(y, x)); 
    return angle; 
} 
関連する問題