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

Marker view rotation not working correctly #6816

Closed

Description

@cammace

Marker view rotation is off by ~90 degrees from the expected value. Reproducible in the OffRouteActivity in the demo app

cc: @mapbox/android

Activity

  1. added
    Android
    on Oct 25, 2016
  2. added this to the android-v4.2.0 milestone on Oct 25, 2016
  3. tobrun commented on Oct 26, 2016

    @tobrun
    Member

    ezgif com-video-to-gif 14

    Not reproducible with suggested OffRouteActivity and latest beta.
    You probably have animations disabled in developer options?

  4. tobrun commented on Oct 26, 2016

    @tobrun
    Member

    I had @ivovandongen retest and he is seeing something different:
    image

  5. reopened this on Oct 26, 2016
  6. mdakram commented on Oct 26, 2016

    @mdakram

    hi @tobrun can you please check why user tracking mode in current beta 4.UserLocation marker's heading is always facing up. thanks

  7. tobrun commented on Oct 26, 2016

    @tobrun
    Member

    Tracked it down to updating the rotation while the animation is still ongoing. Regression from commit e598bbf. I'm going to keep the input limitation from that commit but replace the rotateBy with a rotate animation. This was initially implemented on request from a client but is no longer needed. The requested use-case from them was solved by using MarkerViewManager.getView(MarkerView marker) and calling rotation directly on the view instead.

  8. tobrun commented on Oct 26, 2016

    @tobrun
    Member

    @mdakram
    When you have LocationTracking enabled and combine this with a tracking mode, the heading should always face up. The underlying map should adapt the camera position to match the direction you are going to (gps) or your device is pointing to (compass).

    Note that @cammace reported an issue on compass tracking already: #6815

  9. tobrun commented on Oct 26, 2016

    @tobrun
    Member

    Instead of applying #6816 (comment), now thinking of fixing up rotateBy with:

        /**
         * Animate a MarkerView with a given rotation.
         *
         * @param marker   the MarkerView to rotate by
         * @param rotation the rotation by value
         */
        public void animateRotationBy(@NonNull MarkerView marker, float rotation) {
            View convertView = markerViewMap.get(marker);
            if (convertView != null) {
                convertView.animate().cancel();
                // calculate new direction
                float diff = rotation - convertView.getRotation();
                if (diff > 180.0f) {
                    diff -= 360.0f;
                } else if (diff < -180.0f) {
                    diff += 360.f;
                }
                AnimatorUtils.rotateBy(convertView, diff);
            }
        }

    This will cancel the ongoing animation, take the current rotation and calculate the difference. In previous versions we used the previous set rotation but this was not taking in account that an animation was still ongoing.

  10. self-assigned this
    on Oct 26, 2016
  11. tobrun commented on Oct 26, 2016

    @tobrun
    Member

    Merged in release branch with #6826.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Androidbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions