MGLMapCamera
@interface MGLMapCamera : NSObject <NSSecureCoding, NSCopying>
An MGLMapCamera
object represents a viewpoint from which the user observes some point on an MGLMapView
.
centerCoordinate
Coordinate at the center of the map view.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
CLLocationCoordinate2D centerCoordinate;
Swift
var centerCoordinate: CLLocationCoordinate2D { get set }
heading
Heading measured in degrees clockwise from true north.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
CLLocationDirection heading;
Swift
var heading: CLLocationDirection { get set }
pitch
Pitch toward the horizon measured in degrees, with 0 degrees resulting in a two-dimensional map.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite) CGFloat pitch;
Swift
var pitch: CGFloat { get set }
altitude
The altitude (measured in meters) above the map at which the camera is situated.
The altitude is the distance from the viewpoint to the map, perpendicular to the map plane. This property does not account for physical elevation.
This property’s value may be less than that of the viewingDistance
property. Setting this property automatically updates the viewingDistance
property based on the pitch
property’s current value.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
CLLocationDistance altitude;
Swift
var altitude: CLLocationDistance { get set }
viewingDistance
The straight-line distance from the viewpoint to the centerCoordinate
.
Setting this property automatically updates the altitude
property based on the pitch
property’s current value.
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite)
CLLocationDistance viewingDistance;
Swift
var viewingDistance: CLLocationDistance { get set }
+camera
Returns a new camera with all properties set to 0.
Declaration
Objective-C
+ (nonnull instancetype)camera;
+cameraLookingAtCenterCoordinate:fromEyeCoordinate:eyeAltitude:
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.
+cameraLookingAtCenterCoordinate:acrossDistance:pitch:heading:
Returns a new camera with the given distance, pitch, and heading.
This method interprets the distance as a straight-line distance from the viewpoint to the center coordinate. To specify the altitude of the viewpoint, use the -cameraLookingAtCenterCoordinate:altitude:pitch:heading:
method.
Declaration
Objective-C
+ (nonnull instancetype)
cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
acrossDistance:(CLLocationDistance)distance
pitch:(CGFloat)pitch
heading:(CLLocationDirection)heading;
Swift
convenience init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D, acrossDistance 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 than 0
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 value 90
means the top of the map is pointing due east. The value 180
means the top of the map points due south, and so on.
+cameraLookingAtCenterCoordinate:altitude:pitch:heading:
Returns a new camera with the given altitude, pitch, and heading.
Declaration
Objective-C
+ (nonnull instancetype)
cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
altitude:(CLLocationDistance)altitude
pitch:(CGFloat)pitch
heading:(CLLocationDirection)heading;
Swift
convenience init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D, altitude: CLLocationDistance, pitch: CGFloat, heading: CLLocationDirection)
Parameters
centerCoordinate
The geographic coordinate on which the map should be centered.
altitude
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.
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 than 0
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 value 90
means the top of the map is pointing due east. The value 180
means the top of the map points due south, and so on.
+cameraLookingAtCenterCoordinate:fromDistance:pitch:heading:
Deprecated
Use -cameraLookingAtCenterCoordinate:acrossDistance:pitch:heading: or -cameraLookingAtCenterCoordinate:altitude:pitch:heading:.
Note
This initializer incorrectly interprets the distance
parameter. To specify the straight-line distance from the viewpoint to centerCoordinate
, use the -cameraLookingAtCenterCoordinate:acrossDistance:pitch:heading:
method. To specify the altitude of the viewpoint, use the -cameraLookingAtCenterCoordinate:altitude:pitch:heading:
method, which has the same behavior as this initializer.
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)
-isEqualToMapCamera:
Returns a Boolean value indicating whether the given camera is functionally equivalent to the receiver.
Unlike -isEqual:
, this method returns YES
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.
iOS SDK
Examples
SDK JS Reference
- Annotations
- Appendices
- NSExpression(MGLAdditions)
- NSValue(MGLAdditions)
- NSValue(MGLCircleStyleLayerAdditions)
- NSValue(MGLFillExtrusionStyleLayerAdditions)
- NSValue(MGLFillStyleLayerAdditions)
- NSValue(MGLHillshadeStyleLayerAdditions)
- NSValue(MGLLineStyleLayerAdditions)
- NSValue(MGLRasterStyleLayerAdditions)
- NSValue(MGLSymbolStyleLayerAdditions)
- MGLAccountManager
- MGLAnnotationImage
- MGLAnnotationView
- MGLAttributedExpression
- MGLAttributionInfo
- MGLBackgroundStyleLayer
- MGLCircleStyleLayer
- MGLClockDirectionFormatter
- MGLCompassButton
- MGLCompassDirectionFormatter
- MGLComputedShapeSource
- MGLCoordinateFormatter
- MGLDistanceFormatter
- MGLFillExtrusionStyleLayer
- MGLFillStyleLayer
- MGLForegroundStyleLayer
- MGLHeatmapStyleLayer
- MGLHillshadeStyleLayer
- MGLImageSource
- MGLLight
- MGLLineStyleLayer
- MGLLoggingConfiguration
- MGLMapCamera
- MGLMapSnapshot
- MGLMapSnapshotOptions
- MGLMapSnapshotOverlay
- MGLMapSnapshotter
- MGLMapView
- MGLMultiPoint
- MGLMultiPolygon
- MGLMultiPolyline
- MGLNetworkConfiguration
- MGLOfflinePack
- MGLOfflineStorage
- MGLPointAnnotation
- MGLPointCollection
- MGLPolygon
- MGLPolyline
- MGLRasterStyleLayer
- MGLRasterTileSource
- MGLShape
- MGLShapeCollection
- MGLShapeOfflineRegion
- MGLShapeSource
- MGLSource
- MGLStyle
- MGLStyleLayer
- MGLSymbolStyleLayer
- MGLTilePyramidOfflineRegion
- MGLTileSource
- MGLUserLocation
- MGLUserLocationAnnotationView
- MGLUserLocationAnnotationViewStyle
- MGLVectorStyleLayer
- MGLVectorTileSource
- MGLAnnotationVerticalAlignment
- MGLAnnotationViewDragState
- MGLAttributionInfoStyle
- MGLCirclePitchAlignment
- MGLCircleScaleAlignment
- MGLCircleTranslationAnchor
- MGLDEMEncoding
- MGLErrorCode
- MGLFillExtrusionTranslationAnchor
- MGLFillTranslationAnchor
- MGLHillshadeIlluminationAnchor
- MGLIconAnchor
- MGLIconPitchAlignment
- MGLIconRotationAlignment
- MGLIconTextFit
- MGLIconTranslationAnchor
- MGLLightAnchor
- MGLLineCap
- MGLLineJoin
- MGLLineTranslationAnchor
- MGLLoggingLevel
- MGLMapDebugMaskOptions
- MGLOfflinePackState
- MGLOrnamentPosition
- MGLOrnamentVisibility
- MGLRasterResamplingMode
- MGLResourceKind
- MGLSymbolPlacement
- MGLSymbolZOrder
- MGLTextAnchor
- MGLTextJustification
- MGLTextPitchAlignment
- MGLTextRotationAlignment
- MGLTextTransform
- MGLTextTranslationAnchor
- MGLTextWritingMode
- MGLTileCoordinateSystem
- MGLUserTrackingMode
- Formatters
- Geometry
- Location Updates
- Maps
- Offline Maps
- Other Categories
- Other Classes
- Other Constants
- Other Enumerations
- Other Functions
- Other Protocols
- Other Structures
- Other Type Definitions
- Primitive Shapes
- MGLAnnotation
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLCluster
- MGLComputedShapeSourceDataSource
- MGLFeature
- MGLLocationManager
- MGLLocationManagerDelegate
- MGLMapSnapshotterDelegate
- MGLMapViewDelegate
- MGLOfflineRegion
- MGLOfflineStorageDelegate
- MGLOverlay
- MGLStylable
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- Style Content
- Style Layers
- Style Primitives
- Styling the Map
- MGLCoordinateBounds
- MGLCoordinateQuad
- MGLCoordinateSpan
- MGLOfflinePackProgress
- MGLSphericalPosition
- MGLTransition
- User Interaction
- Customizing Fonts
- Information for Style Authors
- Gesture Recognizers
- Info.plist Keys
- Migrating to Expressions
- Predicates and expressions
- Tile URL Templates
- Working with GeoJSON Data