Using custom camera animations
package com.mapbox.maps.testapp.examples.camera
import android.os.Bundle
import android.view.animation.AccelerateDecelerateInterpolator
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.geojson.Point
import com.mapbox.maps.MapView
import com.mapbox.maps.MapboxMap
import com.mapbox.maps.Style
import com.mapbox.maps.dsl.cameraOptions
import com.mapbox.maps.plugin.animation.CameraAnimatorOptions.Companion.cameraAnimatorOptions
import com.mapbox.maps.plugin.animation.camera
class LowLevelCameraAnimatorActivity : AppCompatActivity() {
private lateinit var mapboxMap: MapboxMap
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val mapView = MapView(this)
setContentView(mapView)
mapboxMap = mapView.mapboxMap
mapboxMap.setCamera(CAMERA_TARGET)
mapboxMap.loadStyle(
Style.STANDARD
) {
mapView.camera.apply {
val bearing = createBearingAnimator(cameraAnimatorOptions(-45.0)) {
duration = 4000
interpolator = AccelerateDecelerateInterpolator()
}
val zoom = createZoomAnimator(
cameraAnimatorOptions(14.0) {
startValue(3.0)
}
) {
duration = 4000
interpolator = AccelerateDecelerateInterpolator()
}
val pitch = createPitchAnimator(
cameraAnimatorOptions(55.0) {
startValue(0.0)
}
) {
duration = 4000
interpolator = AccelerateDecelerateInterpolator()
}
playAnimatorsSequentially(zoom, pitch, bearing)
}
}
}
private companion object {
private val CAMERA_TARGET = cameraOptions {
center(Point.fromLngLat(-74.0060, 40.7128))
zoom(3.0)
}
}
}
この{Type}は役に立ちましたか?