Programming

GMSGroundOverlay 애니메이션-CATiledLayer를 사용해야합니까?

procodes 2020. 8. 19. 20:12
반응형

GMSGroundOverlay 애니메이션-CATiledLayer를 사용해야합니까?


iOS 용 Google지도 SDK 최신 버전 1.2.1.2944를 사용하여 GMSGroundOverlay. 사용자는 이미지 시퀀스를 제어 할 수 있으므로 애니메이션을 사용하는 UIImage것은 슬프게도 불가능하므로 UIImage즉시 로드 하고 있습니다. 이 ( GMSGroundOverlay.icon가) UIImage업데이트중인로 설정되었습니다.

높은 메모리 사용량 외에도 1000px x 1000px 이상의 UIImage사용 을 오버레이하려고 할 때마다 충돌이 발생한다는 한계에 부딪힌 것 같습니다 GMSGroundOverlay.icon. UIImage1000px x 1000px를 참조 하면 충돌이 발생합니다.

CATiledLayer이미지를 처리하여 메모리에만로드 한 다음 아이콘 속성에로드하는 데 활용해야한다는 생각이 GMSGroundOverlay들지만, CATiledLayeriOS SDK 용 Google지도를 사용 하고 이미지를 애니메이션으로 시퀀싱 한 경험이있는 사람이 GMSGroundOverlay있습니까?


pressanswer.com에서이 답변을 받았습니다. 도움이 될 것 같습니다.

현재는 애니메이션에 "위치"키 경로를 사용할 수 없으므로 "위도"및 "경도"키 경로를 별도로 사용하여 애니메이션을 적용했습니다.

먼저 점을 계산하고 위도 값 (y)과 경도 (x)에 대해 하나씩 두 개의 개별 배열에 추가 한 다음 CAKeyFrameAnimation의 values ​​속성을 사용하여 애니메이션을 적용합니다. CAKeyFrameAnimation 개체 2 개 (각 축당 1 개)를 만들고 CAAnimationGroup을 사용하여 그룹화하고 애니메이션을 적용하여 원을 만듭니다.

내 방정식에서 저는 타원형 경로를 생성 할 수 있도록 각 축의 반경 길이를 변경합니다.

NSMutableArray *latitudes = [NSMutableArray arrayWithCapacity:21];
    NSMutableArray *longitudes = [NSMutableArray arrayWithCapacity:21];
    for (int i = 0; i <= 20; i++) {
        CGFloat radians = (float)i * ((2.0f * M_PI) / 20.0f);

        // Calculate the x,y coordinate using the angle
        CGFloat x = hDist * cosf(radians);
        CGFloat y = vDist * sinf(radians);

        // Calculate the real lat and lon using the
        // current lat and lon as center points.
        y = marker.position.latitude + y;
        x = marker.position.longitude + x;


        [longitudes addObject:[NSNumber numberWithFloat:x]];
        [latitudes addObject:[NSNumber numberWithFloat:y]];
    }

    CAKeyframeAnimation *horizontalAnimation = [CAKeyframeAnimation animationWithKeyPath:@"longitude"];
    horizontalAnimation.values = longitudes;
    horizontalAnimation.duration = duration;

    CAKeyframeAnimation *verticleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"latitude"];
    verticleAnimation.values = latitudes;
    verticleAnimation.duration = duration;

    CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
    group.animations = @[horizontalAnimation, verticleAnimation];
    group.duration = duration;
    group.repeatCount = HUGE_VALF;
    [marker.layer addAnimation:group forKey:[NSString stringWithFormat:@"circular-%@",marker.description]];

참고 URL : https://stackoverflow.com/questions/16211367/gmsgroundoverlay-animating-should-i-be-using-a-catiledlayer

반응형