GMSCameraPosition.h 4.5 KB

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