GMSGroundOverlay动画 - 我应该使用CATiledLayer吗?

Rob*_*ler 100 crash overlay catiledlayer ios google-maps-sdk-ios

我正在尝试使用Google Maps for iOS SDK最新版本1.2.1.2944来动画a GMSGroundOverlay.用户可以控制图像序列,因此使用动画UIImage不是一种可能的遗憾,所以我在动态加载UIImage.将GMSGroundOverlay.icon被设置为UIImage正在更新.

除了高内存使用情况,我似乎在已经达成的限制每当我试图覆盖一个UIImage使用GMSGroundOverlay.icon是超过1000像素X 1000像素,它崩溃.引用UIImage1000px x 1000px可以解决崩溃问题.

虽然我可能会利用CATiledLayer处理图像只加载到内存中,然后进入图标属性GMSGroundOverlay,但是有没有人有任何使用CATiledLayerGoogle Maps for iOS SDK和将图像排序为动画的经验GMSGroundOverlay

Ras*_*ara 1

我从 Pressinganswer.com 得到了这个答案,我想它可能对你有帮助。

由于目前我无法使用“位置”键路径进行动画处理,因此我最终分别使用“纬度”和“经度”键路径对其进行动画处理。

首先计算点并将它们添加到 2 个单独的数组中,一个用于纬度值 (y),一个用于经度 (x),然后使用 CAKeyFrameAnimation 中的 value 属性进行动画处理。创建 2 个 CAKeyFrameAnimation 对象(每个轴 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]];
Run Code Online (Sandbox Code Playgroud)