![](/img/trans.png)
[英]Google Maps SDK for Android: Smoothly animating the camera to a new location, rendering all the tiles along the way
[英]Android Google Maps animating every location
我有一個LatLng的ArrayList,並且在onMapReady(GoogleMap googleMap)的forloop中,我希望對從位置到另一個的移動進行動畫處理。
我嘗試在for循環中執行此操作:
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currLatLng,10), 1000, null);
而動畫僅發生在最后一個位置。
我將如何去做? 我應該使用animateCamera()方法的最后一個參數嗎? (可取消的回調)
我的直覺是正確的。
animateCamera
的最后一個參數是CancellableCallback()
接口。
我所做的是使一個名為nimateToLocationAtIndex(int index)
然后調用:
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 10), 2000, new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
// Placing a marker on the position after animated
Marker marker = mMap.addMarker(markerOptions);
animateLocationMovement(i+1);
}
盡管我遇到了另一個問題,即下一個位置的地圖沒有加載,所以看起來好像動畫很慢,但這可以根據需要對位置進行動畫處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.