您可以向 3D 地图添加镜头路径动画,为用户提供更具沉浸感的体验。镜头路径动画可以飞往、环绕或 组合使用,以将镜头动画到地图上的某个点,包括指定其 海拔高度 。
飞往
以下代码示例演示了如何使用
Map.flyCameraTo
方法,以动画方式将镜头飞往 3D 地图上的特定点。
Map(mode: .hybrid)
.flyCameraTo(
camera: .init(
center: .init(
latitude: 47.6210296,
longitude: -122.3496903,
altitude: 585), // meters above mean sea level
heading: 149.0,
tilt: 77.0,
roll: 0.0,
range: 4000),
duration: 5,
trigger: animate,
completion: {}
)
环绕
以下代码示例演示了如何使用
Map.flyCameraAround
方法,以动画方式将镜头环绕 3D 地图上的特定点。
Map(mode: .hybrid)
.flyCameraAround(
.init(
center: . init(
latitude: 47.6210296,
longitude: -122.3496903,
altitude: 585
),
heading: 149.0,
tilt: 77.0,
roll: 0.0,
range: 3000
),
duration: 90,
repeatCount: 3,
trigger: flyAround,
completion: {}
)