Camera
struct Cameraextension Camera : AdditiveArithmetic, Animatable, Copyable, Equatable, Escapable, VectorArithmeticThe map camera position and orientation.
Usage with the map:
// Usage with an initial camera configuration
Map(
initialCamera: Camera(center: LatLngAltitude(latitude: 37.7749, longitude: -122.4194, altitude: 0)),
mode: .hybrid
)
// Usage with a camera binding
@State private var camera = Camera(center: LatLngAltitude(latitude: 37.7749, longitude: -122.4194, altitude: 0))
Map(camera: $camera, mode: .hybrid)
Usage with fly animations:
struct FlyAnimationExample: View {
@State private var animationTrigger = 0
let targetCamera = Camera(center: LatLngAltitude(latitude: 37.7749, longitude: -122.4194, altitude: 0))
var body: some View {
Map(mode: .hybrid)
.flyCameraTo(targetCamera, trigger: animationTrigger)
.flyCameraAround(targetCamera, trigger: animationTrigger)
}
}
-
Declaration
Swift
static func * (lhs: Camera, rhs: Double) -> Camera -
Adds two values and produces their sum.
The addition operator (
+) calculates the sum of its two arguments. For example:1 + 2 // 3 -10 + 15 // 5 -15 + -5 // -20 21.5 + 3.25 // 24.75You cannot use
+with arguments of different types. To add values of different types, convert one of the values to the other value’s type.let x: Int8 = 21 let y: Int = 1000000 Int(x) + y // 1000021Declaration
Swift
static func + (lhs: Camera, rhs: Camera) -> CameraParameters
lhsThe first value to add.
rhsThe second value to add.
-
Adds two values and stores the result in the left-hand-side variable.
Declaration
Swift
static func += (lhs: inout Camera, rhs: Camera)Parameters
lhsThe first value to add.
rhsThe second value to add.
-
Subtracts one value from another and produces their difference.
The subtraction operator (
-) calculates the difference of its two arguments. For example:8 - 3 // 5 -10 - 5 // -15 100 - -5 // 105 10.5 - 100.0 // -89.5You cannot use
-with arguments of different types. To subtract values of different types, convert one of the values to the other value’s type.let x: UInt8 = 21 let y: UInt = 1000000 y - UInt(x) // 999979Declaration
Swift
static func - (lhs: Camera, rhs: Camera) -> CameraParameters
lhsA numeric value.
rhsThe value to subtract from
lhs. -
Subtracts the second value from the first and stores the difference in the left-hand-side variable.
Declaration
Swift
static func -= (lhs: inout Camera, rhs: Camera)Parameters
lhsA numeric value.
rhsThe value to subtract from
lhs. -
Declaration
Swift
static func / (lhs: Camera, rhs: Double) -> Camera -
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values
aandb,a == bimplies thata != bisfalse.Declaration
Swift
static func == (a: Camera, b: Camera) -> Bool -
The type defining the data to animate.
Declaration
Swift
typealias AnimatableData = Camera -
Declaration
Swift
var altitudeMode: AltitudeMode -
The data to animate.
Declaration
Swift
var animatableData: Camera { get set } -
Declaration
Swift
var center: LatLngAltitude -
Declaration
Swift
var fieldOfView: Angle { get set } -
Declaration
Swift
var heading: Double -
Creates a camera with the specified position and orientation.
Declaration
Swift
init(center: LatLngAltitude, heading: Double = 0.0, tilt: Double = 0.0, roll: Double = 0.0, range: Double = 1e5, fieldOfView: Angle = .degrees(35.0), altitudeMode: AltitudeMode = .absolute)Parameters
centerThe center coordinate of the camera.
headingThe heading of the camera in degrees.
tiltThe tilt of the camera in degrees.
rollThe roll of the camera in degrees.
rangeThe distance from the camera to the center coordinate in meters.
fieldOfViewThe field of view of the camera.
altitudeModeThe altitude mode of the camera. Note that
altitudeModeis only relevant forflyCameraToandflyCameraAroundanimations. -
Returns the dot-product of this vector arithmetic instance with itself.
Declaration
Swift
var magnitudeSquared: Double { get } -
Declaration
Swift
var range: Double -
Declaration
Swift
var roll: Double -
Multiplies each component of this value by the given value.
Declaration
Swift
mutating func scale(by rhs: Double) -
Declaration
Swift
var tilt: Double -
The zero value.
Zero is the identity element for addition. For any value,
x + .zero == xand.zero + x == x.Declaration
Swift
static var zero: Camera { get }