3D 地図にカメラパス アニメーションを追加すると、ユーザーに没入感の高いエクスペリエンスを提供できます。カメラパス アニメーションは、Camera を地図上のポイントに移動したり、ポイントの周囲を移動したり、それらを組み合わせて移動したりできます。移動先のポイントには、高度や altitudeMode を指定することもできます。
アニメーションの Camera を構成するときに、altitudeMode プロパティを設定(または setAltitudeMode を呼び出し)して、カメラの高度の解釈方法を指定できます。
AltitudeMode.ABSOLUTE: 高度を平均海面からのメートル数として解釈します(指定しない場合のデフォルト値)。AltitudeMode.RELATIVE_TO_GROUND: 標高を、カメラの中心点における地表からの高さ(メートル単位)として解釈します。AltitudeMode.RELATIVE_TO_MESH: 高度を、カメラの中心点にある最も高い 3D メッシュ サーフェス(建物や木など)からの高さ(メートル単位)として解釈します。
ジャンプ
次のコードサンプルは、FlyToOptions 構成で GoogleMap3D の flyCameraTo メソッドを呼び出して、Camera をアニメーション化し、3D 地図上の特定のポイントに移動する方法を示しています。
// Add imports and define constants
import com.google.android.gms.maps3d.model.AltitudeMode
import com.google.android.gms.maps3d.model.FlyToOptions
import com.google.android.gms.maps3d.model.FlyAroundOptions
import com.google.android.gms.maps3d.model.Camera
import com.google.android.gms.maps3d.model.Map3DMode
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.setMapMode(Map3DMode.HYBRID)
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
altitudeMode = AltitudeMode.RELATIVE_TO_GROUND
}
durationInMillis = 2000
}
)
飛び回る
次のコードサンプルは、FlyAroundOptions 構成を使用して GoogleMap3D で flyCameraAround メソッドを呼び出し、Camera をアニメーション化して 3D 地図上の特定のポイントを周回する方法を示しています。
// Add imports and define constants
import com.google.android.gms.maps3d.model.AltitudeMode
import com.google.android.gms.maps3d.model.Map3DMode
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.setMapMode(Map3DMode.HYBRID)
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
altitudeMode = AltitudeMode.RELATIVE_TO_GROUND
}
durationInMillis = 5000
rounds = 1.0 // Number of rotations - can be fractional
}
)