MBMCameraManager.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. // This file is generated and will be overwritten automatically.
  2. #import <Foundation/Foundation.h>
  3. #import <CoreLocation/CoreLocation.h>
  4. @class MBXExpected<__covariant Value, __covariant Error>;
  5. @class MBXGeometry;
  6. #import <MapboxCoreMaps/MBMStyleManager.h>
  7. @class MBMCameraBounds;
  8. @class MBMCameraBoundsOptions;
  9. @class MBMCameraOptions;
  10. @class MBMCameraState;
  11. @class MBMCoordinateBounds;
  12. @class MBMCoordinateBoundsZoom;
  13. @class MBMEdgeInsets;
  14. @class MBMFreeCameraOptions;
  15. @class MBMScreenBox;
  16. @class MBMScreenCoordinate;
  17. /** Interface for managing camera. */
  18. NS_SWIFT_NAME(CameraManager)
  19. __attribute__((visibility ("default")))
  20. @interface MBMCameraManager : MBMStyleManager
  21. /**
  22. * Convenience method that returns the `camera options` object for given parameters.
  23. *
  24. * @param bounds The `coordinate bounds` of the camera.
  25. * @param padding The `edge insets` of the camera.
  26. * @param bearing The bearing of the camera.
  27. * @param pitch The pitch of the camera.
  28. *
  29. * @return The `camera options` object representing the provided parameters.
  30. */
  31. - (nonnull MBMCameraOptions *)cameraForCoordinateBoundsForBounds:(nonnull MBMCoordinateBounds *)bounds
  32. padding:(nonnull MBMEdgeInsets *)padding
  33. bearing:(nullable NSNumber *)bearing
  34. pitch:(nullable NSNumber *)pitch __attribute((ns_returns_retained));
  35. /**
  36. * Convenience method that returns the `camera options` object for given parameters.
  37. *
  38. * @param coordinates The `coordinates` representing the bounds of the camera.
  39. * @param padding The `edge insets` of the camera.
  40. * @param bearing The bearing of the camera.
  41. * @param pitch The pitch of the camera.
  42. *
  43. * @return The `camera options` object representing the provided parameters.
  44. */
  45. - (nonnull MBMCameraOptions *)cameraForCoordinatesForCoordinates:(nonnull NSArray<CLLocation *> *)coordinates
  46. padding:(nonnull MBMEdgeInsets *)padding
  47. bearing:(nullable NSNumber *)bearing
  48. pitch:(nullable NSNumber *)pitch __attribute((ns_returns_retained));
  49. /**
  50. * Convenience method that adjusts the provided `camera options` object for given parameters.
  51. *
  52. * Returns the provided `camera` options with zoom adjusted to fit `coordinates` into the `box`, so that `coordinates` on the left,
  53. * top, right, and bottom of the effective `camera` center at the principal point of the projection (defined by `padding`) fit into the `box`.
  54. * Returns the provided `camera` options object unchanged upon an error.
  55. *
  56. * The method fails if the principal point is positioned outside of the `box`
  57. * or if there is no sufficient screen space, defined by principal point and the `box`, to fit the geometry.
  58. * Additionally, in cases when the principal point is positioned exactly on one of the edges of the `box`,
  59. * any geometry point that spans further than that edge on the same axis cannot possibly be framed and is ignored for zoom level calculation purposes.
  60. *
  61. * This API isn't supported by Globe projection.
  62. *
  63. * @param coordinates The `coordinates` representing the bounds of the camera.
  64. * @param camera The `camera options` for which zoom should be adjusted. Note that the `camera.center`, and `camera.zoom` (as fallback) is required.
  65. * @param box The `screen box` into which `coordinates` should fit.
  66. *
  67. * @return The `camera options` object with the zoom level adjusted to fit `coordinates` into the `box`.
  68. */
  69. - (nonnull MBMCameraOptions *)cameraForCoordinatesForCoordinates:(nonnull NSArray<CLLocation *> *)coordinates
  70. camera:(nonnull MBMCameraOptions *)camera
  71. box:(nonnull MBMScreenBox *)box __attribute((ns_returns_retained));
  72. /**
  73. * Convenience method that returns the `camera options` object for given parameters.
  74. *
  75. * @param geometry The `geometry` representing the bounds of the camera.
  76. * @param padding The `edge insets` of the camera.
  77. * @param bearing The bearing of the camera.
  78. * @param pitch The pitch of the camera.
  79. *
  80. * @return The `camera options` object representing the provided parameters.
  81. */
  82. - (nonnull MBMCameraOptions *)cameraForGeometryForGeometry:(nonnull MBXGeometry *)geometry
  83. padding:(nonnull MBMEdgeInsets *)padding
  84. bearing:(nullable NSNumber *)bearing
  85. pitch:(nullable NSNumber *)pitch __attribute((ns_returns_retained));
  86. /**
  87. * Returns the `coordinate bounds` for a given camera.
  88. *
  89. * Note that if the given `camera` shows the antimeridian, the returned wrapped `coordinate bounds`
  90. * might not represent the minimum bounding box.
  91. *
  92. * @param camera The `camera options` to use for calculating `coordinate bounds`.
  93. *
  94. * @return The `coordinate bounds` object representing a given `camera`.
  95. *
  96. */
  97. - (nonnull MBMCoordinateBounds *)coordinateBoundsForCameraForCamera:(nonnull MBMCameraOptions *)camera __attribute((ns_returns_retained));
  98. /**
  99. * Returns the `coordinate bounds` for a given camera.
  100. *
  101. * This method is useful if the `camera` shows the antimeridian.
  102. *
  103. * @param camera The `camera options` to use for calculating `coordinate bounds`.
  104. *
  105. * @return The `coordinate bounds` object representing a given `camera`.
  106. *
  107. */
  108. - (nonnull MBMCoordinateBounds *)coordinateBoundsForCameraUnwrappedForCamera:(nonnull MBMCameraOptions *)camera __attribute((ns_returns_retained));
  109. /**
  110. * Returns the `coordinate bounds` and the `zoom` for a given `camera`.
  111. *
  112. * Note that if the given `camera` shows the antimeridian, the returned wrapped `coordinate bounds`
  113. * might not represent the minimum bounding box.
  114. *
  115. * @param camera The `camera options` to use for calculating `coordinate bounds` and `zoom`.
  116. *
  117. * @return The object representing `coordinate bounds` and `zoom` for a given `camera`.
  118. *
  119. */
  120. - (nonnull MBMCoordinateBoundsZoom *)coordinateBoundsZoomForCameraForCamera:(nonnull MBMCameraOptions *)camera __attribute((ns_returns_retained));
  121. /**
  122. * Returns the unwrapped `coordinate bounds` and `zoom` for a given `camera`.
  123. *
  124. * This method is useful if the `camera` shows the antimeridian.
  125. *
  126. * @param camera The `camera options` to use for calculating `coordinate bounds` and `zoom`.
  127. *
  128. * @return The object representing `coordinate bounds` and `zoom` for a given `camera`.
  129. *
  130. */
  131. - (nonnull MBMCoordinateBoundsZoom *)coordinateBoundsZoomForCameraUnwrappedForCamera:(nonnull MBMCameraOptions *)camera __attribute((ns_returns_retained));
  132. /**
  133. * Calculates a `screen coordinate` that corresponds to a geographical coordinate
  134. * (i.e., longitude-latitude pair).
  135. *
  136. * The `screen coordinate` is in `platform pixels` relative to the top left corner
  137. * of the map (not of the whole screen).
  138. *
  139. * @param coordinate A geographical `coordinate` on the map to convert to a `screen coordinate`.
  140. *
  141. * @return A `screen coordinate` on the screen in `platform pixels`.
  142. */
  143. - (nonnull MBMScreenCoordinate *)pixelForCoordinateForCoordinate:(CLLocationCoordinate2D)coordinate __attribute((ns_returns_retained));
  144. /**
  145. * Calculates a geographical `coordinate` (i.e., longitude-latitude pair) that corresponds
  146. * to a `screen coordinate`.
  147. *
  148. * The screen coordinate is in `platform pixels`relative to the top left corner
  149. * of the map (not of the whole screen).
  150. *
  151. * @param pixel A `screen coordinate` on the screen in `platform pixels`.
  152. *
  153. * @return A geographical `coordinate` corresponding to a given `screen coordinate`.
  154. */
  155. - (CLLocationCoordinate2D)coordinateForPixelForPixel:(nonnull MBMScreenCoordinate *)pixel;
  156. /**
  157. * Calculates `screen coordinates` that correspond to geographical `coordinates`
  158. * (i.e., longitude-latitude pairs).
  159. *
  160. * The `screen coordinates` are in `platform pixels` relative to the top left corner
  161. * of the map (not of the whole screen).
  162. *
  163. * @param coordinates A geographical `coordinates` on the map to convert to `screen coordinates`.
  164. *
  165. * @return A `screen coordinates` in `platform pixels` for a given geographical `coordinates`.
  166. */
  167. - (nonnull NSArray<MBMScreenCoordinate *> *)pixelsForCoordinatesForCoordinates:(nonnull NSArray<CLLocation *> *)coordinates __attribute((ns_returns_retained));
  168. /**
  169. * Calculates geographical `coordinates` (i.e., longitude-latitude pairs) that correspond
  170. * to `screen coordinates`.
  171. *
  172. * The screen coordinates are in `platform pixels` relative to the top left corner
  173. * of the map (not of the whole screen).
  174. *
  175. * @param pixels A `screen coordinates` in `platform pixels`.
  176. *
  177. * @return A `geographical coordinates` that correspond to a given `screen coordinates`.
  178. */
  179. - (nonnull NSArray<CLLocation *> *)coordinatesForPixelsForPixels:(nonnull NSArray<MBMScreenCoordinate *> *)pixels __attribute((ns_returns_retained));
  180. /**
  181. * Changes the map view by any combination of center, zoom, bearing, and pitch, without an animated transition.
  182. * The map will retain its current values for any details not passed via the camera options argument.
  183. * It is not guaranteed that the provided `camera options` will be set, the map may apply constraints resulting in a
  184. * different `camera state`.
  185. *
  186. * @param cameraOptions The new `camera options` to be set.
  187. */
  188. - (void)setCameraForCameraOptions:(nonnull MBMCameraOptions *)cameraOptions;
  189. /**
  190. * Returns the current `camera state`.
  191. *
  192. * @return The current `camera state`.
  193. */
  194. - (nonnull MBMCameraState *)getCameraState __attribute((ns_returns_retained));
  195. /**
  196. * Sets the map view with the free camera options.
  197. *
  198. * The `free camera options` provides more direct access to the underlying camera entity.
  199. * For backwards compatibility the state set using this API must be representable with
  200. * `camera options` as well. Parameters are clamped to a valid range or discarded as invalid
  201. * if the conversion to the pitch and bearing presentation is ambiguous. For example orientation
  202. * can be invalid if it leads to the camera being upside down or the quaternion has zero length.
  203. *
  204. * @param freeCameraOptions The `free camera options` to set.
  205. */
  206. - (void)setCameraForFreeCameraOptions:(nonnull MBMFreeCameraOptions *)freeCameraOptions;
  207. /**
  208. * Gets the map's current free camera options. After mutation, it should be set back to the map.
  209. *
  210. * @return The current `free camera options`.
  211. */
  212. - (nonnull MBMFreeCameraOptions *)getFreeCameraOptions __attribute((ns_returns_retained));
  213. /**
  214. * Returns the `camera bounds` of the map.
  215. * @return A `camera bounds` of the map.
  216. */
  217. - (nonnull MBMCameraBounds *)getBounds __attribute((ns_returns_retained));
  218. /**
  219. * Prepares the drag gesture to use the provided screen coordinate as a pivot `point`. This function should be called each time when user starts a dragging action (e.g. by clicking on the map). The following dragging will be relative to the pivot.
  220. *
  221. * @param point The pivot `screen coordinate`, measured in `platform pixels` from top to bottom and from left to right.
  222. */
  223. - (void)dragStartForPoint:(nonnull MBMScreenCoordinate *)point;
  224. /**
  225. * Calculates target point where camera should move after drag. The method should be called after `dragStart` and before `dragEnd`.
  226. *
  227. * @param fromPoint The `screen coordinate` to drag the map from, measured in `platform pixels` from top to bottom and from left to right.
  228. * @param toPoint The `screen coordinate` to drag the map to, measured in `platform pixels` from top to bottom and from left to right.
  229. *
  230. * @return The `camera options` object showing the end point.
  231. */
  232. - (nonnull MBMCameraOptions *)getDragCameraOptionsForFromPoint:(nonnull MBMScreenCoordinate *)fromPoint
  233. toPoint:(nonnull MBMScreenCoordinate *)toPoint __attribute((ns_returns_retained));
  234. /** Ends the ongoing drag gesture. This function should be called always after the user has ended a drag gesture initiated by `dragStart`. */
  235. - (void)dragEnd;
  236. @end