GMSCameraPosition.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //
  2. // GMSCameraPosition.h
  3. // Google Maps SDK for iOS
  4. //
  5. // Copyright 2013 Google Inc.
  6. //
  7. // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
  8. // Service: https://developers.google.com/maps/terms
  9. //
  10. #import <CoreLocation/CoreLocation.h>
  11. #if __has_feature(modules)
  12. @import GoogleMapsBase;
  13. #else
  14. #import <GoogleMapsBase/GoogleMapsBase.h>
  15. #endif
  16. GMS_ASSUME_NONNULL_BEGIN
  17. /**
  18. * An immutable class that aggregates all camera position parameters.
  19. */
  20. @interface GMSCameraPosition : NSObject<NSCopying, NSMutableCopying>
  21. /**
  22. * Location on the Earth towards which the camera points.
  23. */
  24. @property(nonatomic, readonly) CLLocationCoordinate2D target;
  25. /**
  26. * Zoom level. Zoom uses an exponentional scale, where zoom 0 represents the entire world as a
  27. * 256 x 256 square. Each successive zoom level increases magnification by a factor of 2. So at
  28. * zoom level 1, the world is 512x512, and at zoom level 2, the entire world is 1024x1024.
  29. */
  30. @property(nonatomic, readonly) float zoom;
  31. /**
  32. * Bearing of the camera, in degrees clockwise from true north.
  33. */
  34. @property(nonatomic, readonly) CLLocationDirection bearing;
  35. /**
  36. * The angle, in degrees, of the camera from the nadir (directly facing the Earth). 0 is
  37. * straight down, 90 is parallel to the ground. Note that the maximum angle allowed is dependent
  38. * on the zoom. You can think of it as a series of line segments as a function of zoom, rather
  39. * than a step function. For zoom 16 and above, the maximum angle is 65 degrees. For zoom 10 and
  40. * below, the maximum angle is 30 degrees.
  41. */
  42. @property(nonatomic, readonly) double viewingAngle;
  43. /**
  44. * Designated initializer. Configures this GMSCameraPosition with all available camera properties.
  45. * Building a GMSCameraPosition via this initializer (or by the following convenience constructors)
  46. * will implicitly clamp camera values.
  47. *
  48. * @param target Location on the earth towards which the camera points.
  49. * @param zoom The zoom level near the center of the screen.
  50. * @param bearing Bearing of the camera in degrees clockwise from true north.
  51. * @param viewingAngle The angle, in degrees, of the camera angle from the nadir (directly facing
  52. * the Earth)
  53. */
  54. - (id)initWithTarget:(CLLocationCoordinate2D)target
  55. zoom:(float)zoom
  56. bearing:(CLLocationDirection)bearing
  57. viewingAngle:(double)viewingAngle;
  58. /**
  59. * Convenience constructor for GMSCameraPosition for a particular target and zoom level. This will
  60. * set the bearing and viewingAngle properties of this camera to zero defaults (i.e., directly
  61. * facing the Earth's surface, with the top of the screen pointing north).
  62. */
  63. + (instancetype)cameraWithTarget:(CLLocationCoordinate2D)target zoom:(float)zoom;
  64. /**
  65. * Convenience constructor for GMSCameraPosition, as per cameraWithTarget:zoom:.
  66. */
  67. + (instancetype)cameraWithLatitude:(CLLocationDegrees)latitude
  68. longitude:(CLLocationDegrees)longitude
  69. zoom:(float)zoom;
  70. /**
  71. * Convenience constructor for GMSCameraPosition, with all camera properties as per
  72. * initWithTarget:zoom:bearing:viewingAngle:.
  73. */
  74. + (instancetype)cameraWithTarget:(CLLocationCoordinate2D)target
  75. zoom:(float)zoom
  76. bearing:(CLLocationDirection)bearing
  77. viewingAngle:(double)viewingAngle;
  78. /**
  79. * Convenience constructor for GMSCameraPosition, with latitude/longitude and all other camera
  80. * properties as per initWithTarget:zoom:bearing:viewingAngle:.
  81. */
  82. + (instancetype)cameraWithLatitude:(CLLocationDegrees)latitude
  83. longitude:(CLLocationDegrees)longitude
  84. zoom:(float)zoom
  85. bearing:(CLLocationDirection)bearing
  86. viewingAngle:(double)viewingAngle;
  87. /**
  88. * Get the zoom level at which |meters| distance, at given |coord| on Earth, correspond to the
  89. * specified number of screen |points|.
  90. *
  91. * For extremely large or small distances the returned zoom level may be smaller or larger than the
  92. * minimum or maximum zoom level allowed on the camera.
  93. *
  94. * This helper method is useful for building camera positions that contain specific physical areas
  95. * on Earth.
  96. */
  97. + (float)zoomAtCoordinate:(CLLocationCoordinate2D)coordinate
  98. forMeters:(CLLocationDistance)meters
  99. perPoints:(CGFloat)points;
  100. @end
  101. /** Mutable version of GMSCameraPosition. */
  102. @interface GMSMutableCameraPosition : GMSCameraPosition
  103. @property(nonatomic, assign) CLLocationCoordinate2D target;
  104. @property(nonatomic, assign) float zoom;
  105. @property(nonatomic, assign) CLLocationDirection bearing;
  106. @property(nonatomic, assign) double viewingAngle;
  107. @end
  108. /** The maximum zoom (closest to the Earth's surface) permitted by the map camera. */
  109. FOUNDATION_EXTERN const float kGMSMaxZoomLevel;
  110. /** The minimum zoom (farthest from the Earth's surface) permitted by the map camera. */
  111. FOUNDATION_EXTERN const float kGMSMinZoomLevel;
  112. GMS_ASSUME_NONNULL_END