3D 地図にカメラパス アニメーションを追加すると、ユーザーにより没入感のあるエクスペリエンスを提供できます。カメラパス アニメーションでは、地図上の 1 点に移動したり、その周囲を飛行したりできます。
ジャンプ
次のコードサンプルは、flyCameraTo
メソッドを呼び出して、3D 地図上の特定のポイントに飛行するようにカメラをアニメーション化する方法を示しています。このコードサンプルを使用するには、設定とアプリに 3D 地図を追加するの手順に沿って、基本的な 3D 地図を使用して Android Studio プロジェクトを設定します。次に、MainActivity.kt
ファイルに次のコードを追加します。
// Add imports and define constants import com.google.android.gms.maps3d.model.latLngAltitude const val EMPIRE_STATE_BUILDING_LATITUDE = 40.748233 const val EMPIRE_STATE_BUILDING_LONGITUDE = -73.985663 ... // Add to the onMap3DViewReady method, after the googleMap3D object has been initialized googleMap3D.flyCameraTo( flyToOptions { endCamera = camera { center = latLngAltitude { latitude = EMPIRE_STATE_BUILDING_LATITUDE longitude = EMPIRE_STATE_BUILDING_LONGITUDE altitude = 212.0 // in meters } heading = 34.0 // bearing in degrees tilt = 67.0 // relative to vertical range = 750.0 // distance away from the focal point in meters roll = 0.0 // roll relative to horizontal } durationInMillis = 2_000 } )
飛行する
次のコードサンプルは、flyCameraAround
メソッドを呼び出して、3D 地図上の特定のポイントを飛行するようにカメラをアニメーション化する方法を示しています。このコードサンプルを使用するには、セットアップとアプリに 3D 地図を追加するの手順に沿って、基本的な 3D 地図を使用して Android Studio プロジェクトを設定します。次に、MainActivity.kt
ファイルに次のコードを追加します。
// Add imports and define constants import com.google.android.gms.maps3d.model.latLngAltitude const val EMPIRE_STATE_BUILDING_LATITUDE = 40.748233 const val EMPIRE_STATE_BUILDING_LONGITUDE = -73.985663 ... // Add to the onMap3DViewReady method, after the googleMap3D object has been initialized googleMap3D.flyCameraAround( flyAroundOptions { center = camera { center = latLngAltitude { latitude = EMPIRE_STATE_BUILDING_LATITUDE longitude = EMPIRE_STATE_BUILDING_LONGITUDE altitude = 212.0 } heading = 34.0 tilt = 67.0 range = 750.0 roll = 0.0 } durationInMillis = 5_000 rounds = 1.0 // Number of rotations - can be fractional } )