我知道一般應如何在此基礎上SO問題動畫圓形路徑等CALayers: iPhone - How to make a circle path for a CAKeyframeAnimation?動畫效果GMSMarker圓形路徑
然而,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);
由於關鍵幀動畫將使用「位置」的keyPath,我怎麼能轉換到這2個獨立keypaths(經度和緯度),所以我可以動畫在地圖上的圓圈標記?
任何幫助,非常感謝。
問題,你有興趣在地球上畫一個圓或者在屏幕上畫一個圓圈嗎?如果您對地球上的測地線動畫感興趣,那麼手動插入一系列短線段就是您的前進之路。如果您有興趣在屏幕上爲圈子設置動畫效果,然後在https://code.google.com/p/gmaps-api-issues/issues/entry?template=Maps%上提出動畫「偏移量」的功能請求20SDK%20for%20iOS%20-%20Feature%20Request – Brett
Hi @Brett感謝您的提問。我想要在地球表面的圓形路徑上使標記動起來。有趣的是,GMSMarkerLayer不允許我使用「position」keypath並直接將其轉換爲「緯度」和「經度」,因爲這會立即解決我的問題。插入一系列短線段可以工作,但要求我使用各自的鍵路徑分別對lat和lon進行動畫處理,您是否知道是否有更有效的方法去處理這些問題? – Jamornh
請隨時通過https://code.google.com/p/gmaps-api-issues/issues/entry?template=Maps%20SDK%20for%20iOS%20-%20Feature%20Request提出功能要求 – Brett