Class

CLLocation

The latitude, longitude, and course information reported by the system.

Declaration

class CLLocation : NSObject

Overview

A CLLocation object contains the geographical location and altitude of a device, along with values indicating the accuracy of those measurements and when they were collected. In iOS, a location object also contains course information—that is, the speed and heading in which the device was moving.

Typically, you do not create location objects yourself. After you request location updates from your CLLocationManager object, the system uses onboard sensors to gather location data and report that data to your app. Some services also return previously collected location data, which you can use as context to improve your services. You can always retrieve the most recently collected location from the location property of your CLLocationManager object. You may create location objects yourself when you want to cache custom location data or calculate the distance between two geographical coordinates.

Use CLLocation objects as is and do not subclass them.

Topics

Getting the Location Attributes

var coordinate: CLLocationCoordinate2D

The geographical coordinate information.

var altitude: CLLocationDistance

The altitude, measured in meters.

var floor: CLFloor?

The logical floor of the building in which the user is located.

var horizontalAccuracy: CLLocationAccuracy

The radius of uncertainty for the location, measured in meters.

var verticalAccuracy: CLLocationAccuracy

The accuracy of the altitude value, measured in meters.

var timestamp: Date

The time at which this location was determined.

Measuring the Distance Between Coordinates

func distance(from: CLLocation) -> CLLocationDistance

Returns the distance (measured in meters) from the current object's location to the specified location.

Getting Speed and Course Information

var speed: CLLocationSpeed

The instantaneous speed of the device, measured in meters per second.

var course: CLLocationDirection

The direction in which the device is traveling, measured in degrees and relative to due north.

Data Types

typealias CLLocationSpeed

The velocity (measured in meters per second) at which the device is moving.

typealias CLLocationDirection

An azimuth that is measured in degrees relative to true north.

typealias CLLocationDistance

A distance measurement (measured in meters) from an existing location.

typealias CLLocationAccuracy

The accuracy of a geographical coordinate.

See Also

Location Updates

Getting the User's Location

Learn how to receive location data in your app.

struct CLLocationCoordinate2D

The latitude and longitude associated with a location, specified using the WGS 84 reference frame.

class CLFloor

The floor of a building on which the user's device is located.

class CLVisit

Information about the user's location during a specific period of time.