iOS Developer Library — Pre-Release

Developer

MKMapCamera Class Reference

Options
Deployment Target:

On This Page
Language:

MKMapCamera

An MKMapCamera object describes a virtual camera that you use to define the appearance of the map. A camera object creates a virtual viewpoint above the map surface and affects how the map renders its tiles and other content. You use a camera object to specify the location of the camera on the map, the compass heading that corresponds to the camera’s viewing direction, the pitch of the camera relative to the map perpendicular, and the camera’s altitude above the map. These factors let you create a map view that is not just flat but offers a more 3D-like experience. More...

Inheritance


Import Statement


Swift

import MapKit

Objective-C

@import MapKit;

Availability


Available in iOS 7.0 and later.
  • Returns a new camera object for you to configure.

    Declaration

    Objective-C

    + (instancetype)camera

    Return Value

    A new camera object.

    Discussion

    You must change the values of the returned camera object before using it.

    Availability

    Available in iOS 7.0 and later.

  • Returns a new camera object using the specified viewing angle information.

    Declaration

    Swift

    convenience init!(lookingAtCenterCoordinate centerCoordinate: CLLocationCoordinate2D, fromEyeCoordinate eyeCoordinate: CLLocationCoordinate2D, eyeAltitude eyeAltitude: CLLocationDistance)

    Objective-C

    + (instancetype)cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate fromEyeCoordinate:(CLLocationCoordinate2D)eyeCoordinate eyeAltitude:(CLLocationDistance)eyeAltitude

    Parameters

    centerCoordinate

    The coordinate point on which the map should be centered.

    eyeCoordinate

    The coordinate point at which to place the camera. If the value for this parameter is equal to the value in the centerCoordinate parameter, the map is displayed as if the camera is looking straight down. If this point is offset from the centerCoordinate value, the map is displayed with an appropriate heading and pitch angle.

    eyeAltitude

    The altitude (in meters) above the ground at which to place the camera.

    Return Value

    A new camera object initialized with the specified information.

    Discussion

    This method calculates the required pitch and heading angles to accommodate the specified eye position and altitude.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • The map coordinate at the center of the map view.

    Declaration

    Swift

    var centerCoordinate: CLLocationCoordinate2D

    Objective-C

    @property(nonatomic) CLLocationCoordinate2D centerCoordinate

    Discussion

    This point represents the coordinate on which the map should be centered. When the camera pitch is 0, this property also corresponds to the geographic position of the camera. Changing the pitch to a nonzero value moves the camera but does not affect this property.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • heading heading Property

    The heading of the camera (measured in degrees) relative to true north.

    Declaration

    Swift

    var heading: CLLocationDirection

    Objective-C

    @property(nonatomic) CLLocationDirection heading

    Discussion

    The value 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.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • pitch pitch Property

    The viewing angle of the camera, measured in degrees.

    Declaration

    Swift

    var pitch: CGFloat

    Objective-C

    @property(nonatomic) CGFloat pitch

    Discussion

    A value of 0 results in a camera pointed straight down at the map. Angles greater than 0 result in a camera that is pitched toward the horizon by the specified number of degrees. If the map type is MKMapTypeSatellite or MKMapTypeHybrid, the pitch value is clamped to 0.

    The value in this property may be clamped to a maximum value to maintain map readability. There is no fixed maximum value, though, because the actual maximum value is dependent on the current altitude of the camera.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.

  • altitude altitude Property

    The altitude above the ground, measured in meters.

    Declaration

    Swift

    var altitude: CLLocationDistance

    Objective-C

    @property(nonatomic) CLLocationDistance altitude

    Discussion

    The value you specify for this property must not be less than 0.

    Changing this property may also change the maximum pitch that is allowed for the map. If the current pitch value exceeds the new maximum, the pitch property is clamped to the new maximum.

    Import Statement

    Swift

    import MapKit

    Availability

    Available in iOS 7.0 and later.