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
Creates a coordinate from a latitude and a longitude.
Instance properties
| Property | Description |
|---|---|
latitude read-only | Latitude, in degrees |
longitude read-only | Longitude, 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
| ObjC | JS |
|---|---|
CLLocationCoordinate2DMake(lat, lon) | new CLLocationCoordinate2D(lat, lon) |
coordinate.latitude, coordinate.longitude | coordinate.latitude, coordinate.longitude |
In ObjC it is a struct.
See also
CLLocation: thecoordinateof a location- Structs: other read-only value types