Skip to content

Commit

Permalink
Animate tilt when entering compass mode
Browse files Browse the repository at this point in the history
Helps with map "flicker"
  • Loading branch information
smichel17 committed Feb 8, 2020
1 parent e555718 commit 6437bea
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
import android.graphics.PointF
import android.hardware.SensorManager
import android.location.Location
import android.view.animation.DecelerateInterpolator
import android.view.WindowManager
import androidx.core.content.edit
import com.mapzen.android.lost.api.LocationRequest
Expand Down Expand Up @@ -55,11 +56,14 @@ open class LocationAwareMapFragment : MapFragment() {
private var zoomedYet = false

/** Whether the view should automatically rotate with the compass (like during navigation) */
// Since the with-compass rotation happens with no animation, it's better to start the tilt
// animation abruptly and slide out, rather than sliding in and out (the default interpolator)
private val interpolator = DecelerateInterpolator()
var isCompassMode: Boolean = false
set(value) {
field = value
if (value) {
controller?.updateCameraPosition { tilt = PI.toFloat() / 5f }
controller?.updateCameraPosition(300, interpolator) { tilt = PI.toFloat() / 5f }
}
}

Expand Down

0 comments on commit 6437bea

Please sign in to comment.