この SO の質問に基づいて、円形パスで他の CALayers を通常アニメーション化する方法を理解しています: iPhone - CAKeyframeAnimation の円パスを作成する方法は?
ただし、GMSMarkerLayer は、「位置」キーパスに応答しないように見える CALayers の特別なサブクラスです (そのリンクの指示に従っても、目に見えることは何もありません)、代わりに「緯度」および「経度」キーパスに応答します。代わりは。
私が試したコードは次のとおりです。
CAKeyframeAnimation *circlePathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGMutablePathRef circularPath = CGPathCreateMutable();
CGRect pathRect = CGRectMake(marker.position.latitude, marker.position.longitude, 0.001, 0.001);
CGPathAddEllipseInRect(circularPath, NULL, pathRect);
circlePathAnimation.path = circularPath;
circlePathAnimation.duration = 1.0f;
circlePathAnimation.repeatCount = HUGE_VALF;
[marker.layer addAnimation:circlePathAnimation forKey:[NSString stringWithFormat:@"circular-%@", marker.description]];
CGPathRelease(circularPath);
キーフレーム アニメーションは「位置」キーパスを使用するため、それを 2 つの個別のキーパス (緯度と経度) に変換して、マップ上の円でマーカーをアニメーション化するにはどうすればよいですか?
どんな助けでも大歓迎です。