View
extension View where Self : MapAnimatable
extension View where Self : MapAnimatable, Trigger : Equatable
-
Applies a set of restrictions to the map’s camera behavior.
Use this modifier to constrain how the user can manipulate the map’s viewpoint, ensuring it stays within defined altitude, heading, tilt, or geographical bounds. Applying an empty array removes any existing restrictions.
Map(mode: .hybrid) .cameraRestrictions([ .altitude(0...10000), // Limit zoom-out altitude .tilt(0...60) // Limit maximum tilt ])
Note
If the array has more than one restriction of the same type, the last one will be used.
Declaration
Swift
@MainActor @preconcurrency func cameraRestrictions(_ restrictions: [CameraRestriction]) -> Self
Parameters
restrictions
An array of
CameraRestriction
cases defining the limits to apply to the camera’s movement and orientation.Return Value
The
Map
instance, allowing for further modifier chaining. -
Adds a closure to be called when a place is tapped on the map.
Declaration
Swift
@MainActor @preconcurrency func onPlaceTap(_ handler: @escaping ((PlaceTapInfo) -> Void)) -> Self
Parameters
handler
A closure that the system calls when a place on the map is tapped. This closure receives a
PlaceTapInfo
object containing place identifier and geographic coordinates.Return Value
A new
View
with the tap handler added.
-
Fly the camera around the given center camera with the given duration and rounds.
Declaration
Swift
@MainActor @preconcurrency func flyCameraAround<Trigger>(_ camera: Camera, duration: TimeInterval = 2, rounds: Double = 1, trigger: Trigger, callback: (() -> Void)? = nil) -> ModifiedContent<Self, EquatableChangeModifier<Trigger>>
Parameters
camera
The center camera to fly around.
duration
The duration of the animation in seconds.
rounds
The number of times to fly around the center camera.
trigger
The trigger to fly the camera.
callback
The callback to be called when the animation is complete.
-
Fly the camera to the given destination camera with the given duration.
Declaration
Swift
@MainActor @preconcurrency func flyCameraTo<Trigger>(_ camera: Camera, duration: TimeInterval = 2, trigger: Trigger, completion: (() -> Void)? = nil) -> ModifiedContent<Self, EquatableChangeModifier<Trigger>>
Parameters
camera
The destination camera to fly to.
duration
The duration of the animation in seconds.
trigger
The trigger to fly the camera.