Class

CLLocation

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

Declaration

@interface 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 UIApplicationLaunchOptionsLocationKey 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

Initializing a Location Object

- initWithLatitude:longitude:

Creates a location object with the specified latitude and longitude.

- initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:timestamp:

Creates a location object with the specified coordinate and altitude information.

- initWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp:

Creates a location object with the specified coordinate, altitude, and course information.

Getting the Location Attributes

coordinate

The geographical coordinate information.

altitude

The altitude, measured in meters.

floor

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

horizontalAccuracy

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

verticalAccuracy

The accuracy of the altitude value, measured in meters.

timestamp

The time at which this location was determined.

Measuring the Distance Between Coordinates

- distanceFromLocation:

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

- getDistanceFrom:

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

Deprecated

Getting Speed and Course Information

speed

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

course

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

Data Types

CLLocationSpeed

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

CLLocationDirection

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

CLLocationDistance

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

CLLocationAccuracy

The accuracy of a geographical coordinate.

Relationships

Inherits From

See Also

Location Updates

Getting the User's Location

Receive location data in your app.

CLLocationCoordinate2D

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

CLFloor

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

CLVisit

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