简体   繁体   English

Android Google Maps动画每个位置

[英]Android Google Maps animating every location

I have an ArrayList of LatLng, and in a forloop of onMapReady(GoogleMap googleMap) I would like to animate moving from location to another in order. 我有一个LatLng的ArrayList,并且在onMapReady(GoogleMap googleMap)的forloop中,我希望对从位置到另一个的移动进行动画处理。

I tried doing this in a for loop: 我尝试在for循环中执行此操作:

        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currLatLng,10), 1000, null);

and the animation happens only at the last location. 而动画仅发生在最后一个位置。

How would I go about doing so? 我将如何去做? Should I use the last parameter of animateCamera() method? 我应该使用animateCamera()方法的最后一个参数吗? (Cancellable Callback) (可取消的回调)

My instinct was correct. 我的直觉是正确的。
The last parameter in animateCamera is a CancellableCallback() interface. animateCamera的最后一个参数是CancellableCallback()接口。
What I did is made a method called a nimateToLocationAtIndex(int index) 我所做的是使一个名为nimateToLocationAtIndex(int index)

And then called: 然后调用:

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);
        }

This animates the locations as I wanted, although I ran into another issue where the map at the next location isn't loaded so it may seem like the animation is laggy. 尽管我遇到了另一个问题,即下一个位置的地图没有加载,所以看起来好像动画很慢,但这可以根据需要对位置进行动画处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM