Skip to content

CLLocationCoordinate2D ​

CLLocationCoordinate2D represents the latitude and longitude of a point on Earth, in degrees. North latitudes and east longitudes are positive; south latitudes and west longitudes are negative.

It is a read-only value: its fields cannot be changed and no fields can be added. The coordinate of a CLLocation is one of these; you can also create one yourself with new.

Install @nacrejs/core-location first. See CLLocationManager for how, or Core and capability packages.

Inheritance: CLLocationCoordinate2D does not inherit from any native class.

Constructor ​

CLLocationCoordinate2D()

Creates a coordinate from a latitude and a longitude.

Instance properties ​

PropertyDescription
latitude read-onlyLatitude, in degrees
longitude read-onlyLongitude, in degrees

Examples ​

js
const c = new CLLocationCoordinate2D(39.9042, 116.4074);
console.log(JSON.stringify(c));
console.log(String(c));

Result

  • The first line logs {"latitude":39.9042,"longitude":116.4074}.
  • The second line logs CLLocationCoordinate2D(39.9042, 116.4074).

Corresponding iOS API ​

ObjCJS
CLLocationCoordinate2DMake(lat, lon)new CLLocationCoordinate2D(lat, lon)
coordinate.latitude, coordinate.longitudecoordinate.latitude, coordinate.longitude

In ObjC it is a struct.

See also ​