MKMapCamera Class Reference

Inherits from
Conforms to
Availability
Available in iOS 7.0 and later.
Declared in
MKMapCamera.h

Overview

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.

After creating an instance of this class, configure it with the desired attributes and assign it to your map view. When you assign a camera to your map view, the map centers the map using the value in your camera object’s centerCoordinate property, updating the map’s own region information in the process. The map also takes the camera’s the pitch and altitude into account when calculating the visible region, ensuring that the region always encompasses the visible content on the map.

Tasks

Getting a Camera Object

Configuring the Viewing Angle

Properties

altitude

The altitude above the ground, measured in meters.

@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.

Availability
  • Available in iOS 7.0 and later.
Declared In
MKMapCamera.h

centerCoordinate

The map coordinate at the center of the map view.

@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.

Availability
  • Available in iOS 7.0 and later.
Declared In
MKMapCamera.h

heading

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

@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.

Availability
  • Available in iOS 7.0 and later.
Declared In
MKMapCamera.h

pitch

The viewing angle of the camera, measured in degrees.

@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.

Availability
  • Available in iOS 7.0 and later.
Declared In
MKMapCamera.h

Class Methods

camera

Returns a new camera object for you to configure.

+ (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.
Declared In
MKMapCamera.h

cameraLookingAtCenterCoordinate:fromEyeCoordinate:eyeAltitude:

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

+ (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.

Availability
  • Available in iOS 7.0 and later.
Declared In
MKMapCamera.h