Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

setCenterCoordinate doesn't animate #3283

Closed
tobrun opened this issue Dec 14, 2015 · 9 comments · Fixed by #3396
Closed

setCenterCoordinate doesn't animate #3283

tobrun opened this issue Dec 14, 2015 · 9 comments · Fixed by #3396
Assignees
Labels
Android Mapbox Maps SDK for Android bug

Comments

@tobrun
Copy link
Member

tobrun commented Dec 14, 2015

While investigating #2791 I noticed that setCenterCoordinate(latLng, true /*animated*/) doesn't work. I have added an example feature activity to help out debug this in #3270. I created this separate feature activity because their are too many moving parts in user location tracking to debug this efficiently.

@tobrun tobrun added bug Android Mapbox Maps SDK for Android labels Dec 14, 2015
@tobrun tobrun added this to the android-v2.4.0 milestone Dec 14, 2015
@tobrun
Copy link
Member Author

tobrun commented Dec 14, 2015

cc @bleege @zugaldia

@tobrun
Copy link
Member Author

tobrun commented Dec 17, 2015

Linking #2049

@bleege
Copy link
Contributor

bleege commented Dec 17, 2015

/cc @bsudekum

@bleege bleege modified the milestones: android-v3.0.0, android-v3.1.0 Dec 21, 2015
@tobrun
Copy link
Member Author

tobrun commented Dec 23, 2015

I'm taking a look a this, will try out the new camera api from #3244

@tobrun
Copy link
Member Author

tobrun commented Dec 23, 2015

Using following methods did not give the expected results:

  • flyTo()
  • jumpTo()
  • easeTo()

I was able to animate it correctly using higher level api:

 @UiThread
    public void setCenterCoordinate(@NonNull LatLng centerCoordinate, boolean animated) {
        if (centerCoordinate == null) {
            Log.w(TAG, "centerCoordinate was null, so just returning");
            return;
        }

        CameraPosition cameraPosition = new CameraPosition.Builder(getCameraPosition())
                .target(centerCoordinate)
                .build();

        animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
                (int) ANIMATION_DURATION, null);

}

You can see above result here

@tobrun
Copy link
Member Author

tobrun commented Dec 23, 2015

Next things to do are optimising, backporting and deprecating the setCenterCoordinate method and see how this implementation stacks up in the UserLocationTracking issue

@tobrun
Copy link
Member Author

tobrun commented Dec 23, 2015

Backporting will look like this:

    public void setCenterCoordinate(@NonNull LatLng centerCoordinate, boolean animated) {
        if (centerCoordinate == null) {
            Log.w(TAG, "centerCoordinate was null, so just returning");
            return;
        }

        if (animated) {
            CameraPosition cameraPosition = new CameraPosition.Builder(getCameraPosition())
                    .target(centerCoordinate)
                    .build();
            animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
                    (int) ANIMATION_DURATION, null);
        } else {
            jumpTo(mNativeMapView.getBearing(), centerCoordinate, mNativeMapView.getPitch(), mNativeMapView.getZoom());
        }
    }

For and end-developer the API is unchanged but underneath we are using the newer Camera API.

@tobrun
Copy link
Member Author

tobrun commented Dec 23, 2015

Will not add deprecation notice until validated by co-workers and other methods to be deprecated with replaced implementations are in place (eg. bearing, tilt, etc.).

Will PR current setCenterCoordinate so this issue van be closed down,
will test out user location tracking in its own issue #2791

@bleege
Copy link
Contributor

bleege commented Dec 23, 2015

This looks like it's coming along nicely @tobrun. 👍

Will not add deprecation notice until validated by co-workers and other methods to be deprecated with replaced implementations are in place (eg. bearing, tilt, etc.).

Feel free to roll the replacement of setCenterCoordinate() with moveCamera() from #3309 in with this fix. No need to solve the animation issue for the setCenterCoordinate() methods if those methods are going away.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants