CLLocationCoordinate2D
public struct CLLocationCoordinate2D : CustomDebugStringConvertible, CustomStringConvertible, Sendable
Represents a geographic coordinate in degrees. Apple Documentation
-
Initializes a coordinate with default values.
Declaration
Swift
public init()
-
Initializes a coordinate with specific latitude and longitude.
Declaration
Swift
public init(latitude: CLLocationDegrees, longitude: CLLocationDegrees)
Parameters
latitude
The latitude in degrees.
longitude
The longitude in degrees.
-
The latitude of the coordinate in degrees.
Declaration
Swift
public var latitude: CLLocationDegrees
-
The longitude of the coordinate in degrees.
Declaration
Swift
public var longitude: CLLocationDegrees
-
A user-friendly description of the coordinate.
Declaration
Swift
public var description: String { get }
-
A debug-friendly description of the coordinate.
Declaration
Swift
public var debugDescription: String { get }
-
Calculates the distance to another coordinate using the haversine formula.
Declaration
Swift
func distance(to other: CLLocationCoordinate2D) -> CLLocationDistance
Parameters
other
The destination coordinate
Return Value
Distance in meters
-
Calculates the bearing to another coordinate.
Declaration
Swift
func bearing(to other: CLLocationCoordinate2D) -> CLLocationDirection
Parameters
other
The destination coordinate
Return Value
Bearing in degrees (0-360)
-
Checks if this coordinate is valid (within acceptable latitude/longitude ranges).
Declaration
Swift
var isValid: Bool { get }