MGLMapCamera
@interface MGLMapCamera : NSObject <NSSecureCoding, NSCopying>
An MGLMapCamera
object represents a viewpoint from which the user observes
some point on an MGLMapView
.
-
Coordinate at the center of the map view.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) CLLocationCoordinate2D centerCoordinate;
Swift
var centerCoordinate: CLLocationCoordinate2D { get set }
-
Heading measured in degrees clockwise from true north.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) CLLocationDirection heading;
Swift
var heading: CLLocationDirection { get set }
-
Pitch toward the horizon measured in degrees, with 0 degrees resulting in a two-dimensional map.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat pitch;
Swift
var pitch: CGFloat { get set }
-
Meters above ground level.
Declaration
Objective-C
@property (assign, readwrite, nonatomic) CLLocationDistance altitude;
Swift
var altitude: CLLocationDistance { get set }
-
Returns a new camera with all properties set to 0.
Declaration
Objective-C
+ (nonnull instancetype)camera;
-
Returns a new camera based on information about the camera’s viewpoint and focus point.
Declaration
Objective-C
+ (nonnull instancetype) cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate fromEyeCoordinate:(CLLocationCoordinate2D)eyeCoordinate eyeAltitude:(CLLocationDistance)eyeAltitude;
Swift
convenience init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D, fromEyeCoordinate eyeCoordinate: CLLocationCoordinate2D, eyeAltitude: CLLocationDistance)
Parameters
centerCoordinate
The geographic coordinate on which the map should be centered.
eyeCoordinate
The geometric coordinate at which the camera should be situated.
eyeAltitude
The altitude (measured in meters) above the map at which the camera should be situated. The altitude may be less than the distance from the camera’s viewpoint to the camera’s focus point.
-
Returns a new camera with the given distance, pitch, and heading.
Declaration
Objective-C
+ (nonnull instancetype) cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate fromDistance:(CLLocationDistance)distance pitch:(CGFloat)pitch heading:(CLLocationDirection)heading;
Swift
convenience init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D, fromDistance distance: CLLocationDistance, pitch: CGFloat, heading: CLLocationDirection)
Parameters
centerCoordinate
The geographic coordinate on which the map should be centered.
distance
The straight-line distance from the viewpoint to the
centerCoordinate
.pitch
The viewing angle of the camera, measured in degrees. A value of
0
results in a camera pointed straight down at the map. Angles greater than0
result in a camera angled toward the horizon.heading
The camera’s heading, measured in degrees clockwise from true north. A value of
0
means that the top edge of the map view corresponds to true north. The value90
means the top of the map is pointing due east. The value180
means the top of the map points due south, and so on. -
Returns a Boolean value indicating whether the given camera is functionally equivalent to the receiver.
Unlike
-isEqual:
, this method returnsYES
if the difference between the coordinates, altitudes, pitches, or headings of the two camera objects is negligible.Declaration
Objective-C
- (BOOL)isEqualToMapCamera:(nonnull MGLMapCamera *)otherCamera;
Swift
func isEqual(to otherCamera: MGLMapCamera) -> Bool
Parameters
otherCamera
The camera with which to compare the receiver.
Return Value
A Boolean value indicating whether the two cameras are functionally equivalent.