GMSCameraPosition.h 6.93 KB
Newer Older
Julio Hermosa committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
//
//  GMSCameraPosition.h
//  Google Maps SDK for iOS
//
//  Copyright 2013 Google LLC
//
//  Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
//  Service: https://developers.google.com/maps/terms
//

#import <CoreGraphics/CoreGraphics.h>
#import <CoreLocation/CoreLocation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* An immutable class that aggregates all camera position parameters.
 */
@interface GMSCameraPosition : NSObject<NSCopying, NSMutableCopying>

/**
 * Location on the Earth towards which the camera points.
 */
@property(nonatomic, readonly) CLLocationCoordinate2D target;

/**
 * Zoom level. Zoom uses an exponentional scale, where zoom 0 represents the entire world as a
 * 256 x 256 square. Each successive zoom level increases magnification by a factor of 2. So at
 * zoom level 1, the world is 512x512, and at zoom level 2, the entire world is 1024x1024.
 */
@property(nonatomic, readonly) float zoom;

/**
 * Bearing of the camera, in degrees clockwise from true north.
 */
@property(nonatomic, readonly) CLLocationDirection bearing;

/**
 * The angle, in degrees, of the camera from the nadir (directly facing the Earth). 0 is
 * straight down, 90 is parallel to the ground. Note that the maximum angle allowed is dependent
 * on the zoom. You can think of it as a series of line segments as a function of zoom, rather
 * than a step function. For zoom 16 and above, the maximum angle is 65 degrees. For zoom 10 and
 * below, the maximum angle is 30 degrees.
 */
@property(nonatomic, readonly) double viewingAngle;

/**
 * Designated initializer. Configures this GMSCameraPosition with all available camera properties.
 * Building a GMSCameraPosition via this initializer (or by the following convenience constructors)
 * will implicitly clamp camera values.
 *
 * @param target Location on the earth towards which the camera points.
 * @param zoom The zoom level near the center of the screen.
 * @param bearing Bearing of the camera in degrees clockwise from true north.
 * @param viewingAngle The angle, in degrees, of the camera angle from the nadir (directly facing
 *                     the Earth)
 */
- (instancetype)initWithTarget:(CLLocationCoordinate2D)target
                          zoom:(float)zoom
                       bearing:(CLLocationDirection)bearing
                  viewingAngle:(double)viewingAngle;

/**
 * Convenience initializer for GMSCameraPosition for a particular target and zoom level. This will
 * set the bearing and viewingAngle properties of this camera to zero defaults (i.e., directly
 * facing the Earth's surface, with the top of the screen pointing north).
 *
 * @param target Location on the earth towards which the camera points.
 * @param zoom The zoom level near the center of the screen.
 */
- (instancetype)initWithTarget:(CLLocationCoordinate2D)target zoom:(float)zoom;

/**
 * Convenience initializer for GMSCameraPosition for a particular latitidue, longitude and zoom
 * level. This will set the bearing and viewingAngle properties of this camera to zero defaults
 * (i.e., directly facing the Earth's surface, with the top of the screen pointing north).
 *
 * @param latitude The latitude component of the location towards which the camera points.
 * @param longitude The latitude component of the location towards which the camera points.
 * @param zoom The zoom level near the center of the screen.
 */
- (instancetype)initWithLatitude:(CLLocationDegrees)latitude
                       longitude:(CLLocationDegrees)longitude
                            zoom:(float)zoom;

/**
 * Convenience initializer for GMSCameraPosition, with latitude/longitude and all other camera
 * properties as per -initWithTarget:zoom:bearing:viewingAngle:.
 *
 * @param latitude The latitude component of the location towards which the camera points.
 * @param longitude The latitude component of the location towards which the camera points.
 * @param zoom The zoom level near the center of the screen.
 * @param bearing Bearing of the camera in degrees clockwise from true north.
 * @param viewingAngle The angle, in degrees, of the camera angle from the nadir (directly facing
 *                     the Earth)
 */
- (instancetype)initWithLatitude:(CLLocationDegrees)latitude
                       longitude:(CLLocationDegrees)longitude
                            zoom:(float)zoom
                         bearing:(CLLocationDirection)bearing
                    viewingAngle:(double)viewingAngle;

/**
 * Convenience constructor for GMSCameraPosition for a particular target and zoom level. This will
 * set the bearing and viewingAngle properties of this camera to zero defaults (i.e., directly
 * facing the Earth's surface, with the top of the screen pointing north).
 */
+ (instancetype)cameraWithTarget:(CLLocationCoordinate2D)target zoom:(float)zoom;

/**
 * Convenience constructor for GMSCameraPosition, as per cameraWithTarget:zoom:.
 */
+ (instancetype)cameraWithLatitude:(CLLocationDegrees)latitude
                         longitude:(CLLocationDegrees)longitude
                              zoom:(float)zoom;

/**
 * Convenience constructor for GMSCameraPosition, with all camera properties as per
 * initWithTarget:zoom:bearing:viewingAngle:.
 */
+ (instancetype)cameraWithTarget:(CLLocationCoordinate2D)target
                            zoom:(float)zoom
                         bearing:(CLLocationDirection)bearing
                    viewingAngle:(double)viewingAngle;

/**
 * Convenience constructor for GMSCameraPosition, with latitude/longitude and all other camera
 * properties as per initWithTarget:zoom:bearing:viewingAngle:.
 */
+ (instancetype)cameraWithLatitude:(CLLocationDegrees)latitude
                         longitude:(CLLocationDegrees)longitude
                              zoom:(float)zoom
                           bearing:(CLLocationDirection)bearing
                      viewingAngle:(double)viewingAngle;

/**
 * Get the zoom level at which |meters| distance, at given |coord| on Earth, correspond to the
 * specified number of screen |points|.
 *
 * For extremely large or small distances the returned zoom level may be smaller or larger than the
 * minimum or maximum zoom level allowed on the camera.
 *
 * This helper method is useful for building camera positions that contain specific physical areas
 * on Earth.
 */
+ (float)zoomAtCoordinate:(CLLocationCoordinate2D)coordinate
                forMeters:(CLLocationDistance)meters
                perPoints:(CGFloat)points;

@end

/** Mutable version of GMSCameraPosition. */
@interface GMSMutableCameraPosition : GMSCameraPosition
@property(nonatomic) CLLocationCoordinate2D target;
@property(nonatomic) float zoom;
@property(nonatomic) CLLocationDirection bearing;
@property(nonatomic) double viewingAngle;
@end

/** The maximum zoom (closest to the Earth's surface) permitted by the map camera. */
FOUNDATION_EXTERN const float kGMSMaxZoomLevel;

/** The minimum zoom (farthest from the Earth's surface) permitted by the map camera. */
FOUNDATION_EXTERN const float kGMSMinZoomLevel;

NS_ASSUME_NONNULL_END