GMSPanoramaView.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. //
  2. // GMSPanoramaView.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. #import <GoogleMaps/GMSOrientation.h>
  17. #import <GoogleMaps/GMSPanoramaLayer.h>
  18. @class GMSMarker;
  19. @class GMSPanorama;
  20. @class GMSPanoramaCamera;
  21. @class GMSPanoramaCameraUpdate;
  22. @class GMSPanoramaView;
  23. GMS_ASSUME_NONNULL_BEGIN
  24. /** Delegate for events on GMSPanoramaView. */
  25. @protocol GMSPanoramaViewDelegate<NSObject>
  26. @optional
  27. /**
  28. * Called when starting a move to another panorama.
  29. * This can be the result of interactive navigation to a neighbouring panorama.
  30. * At the moment this method is called, the |view|.panorama is still
  31. * pointing to the old panorama, as the new panorama identified by |panoID|
  32. * is not yet resolved. panoramaView:didMoveToPanorama: will be called when the
  33. * new panorama is ready.
  34. */
  35. - (void)panoramaView:(GMSPanoramaView *)view
  36. willMoveToPanoramaID:(NSString *)panoramaID;
  37. /**
  38. * This is invoked every time the |view|.panorama property changes.
  39. */
  40. - (void)panoramaView:(GMSPanoramaView *)view
  41. didMoveToPanorama:(GMSPanorama *GMS_NULLABLE_PTR)panorama;
  42. /**
  43. * Called when the panorama change was caused by invoking
  44. * moveToPanoramaNearCoordinate:. The coordinate passed to that method will also
  45. * be passed here.
  46. */
  47. - (void)panoramaView:(GMSPanoramaView *)view
  48. didMoveToPanorama:(GMSPanorama *)panorama
  49. nearCoordinate:(CLLocationCoordinate2D)coordinate;
  50. /**
  51. * Called when moveNearCoordinate: produces an error.
  52. */
  53. - (void)panoramaView:(GMSPanoramaView *)view
  54. error:(NSError *)error
  55. onMoveNearCoordinate:(CLLocationCoordinate2D)coordinate;
  56. /**
  57. * Called when moveToPanoramaID: produces an error.
  58. */
  59. - (void)panoramaView:(GMSPanoramaView *)view
  60. error:(NSError *)error
  61. onMoveToPanoramaID:(NSString *)panoramaID;
  62. /**
  63. * Called repeatedly during changes to the camera on GMSPanoramaView. This may
  64. * not be called for all intermediate camera values, but is always called for
  65. * the final position of the camera after an animation or gesture.
  66. */
  67. - (void)panoramaView:(GMSPanoramaView *)panoramaView
  68. didMoveCamera:(GMSPanoramaCamera *)camera;
  69. /**
  70. * Called when a user has tapped on the GMSPanoramaView, but this tap was not
  71. * consumed (taps may be consumed by e.g., tapping on a navigation arrow).
  72. */
  73. - (void)panoramaView:(GMSPanoramaView *)panoramaView didTap:(CGPoint)point;
  74. /**
  75. * Called after a marker has been tapped. May return YES to indicate the event
  76. * has been fully handled and suppress any default behavior.
  77. */
  78. - (BOOL)panoramaView:(GMSPanoramaView *)panoramaView
  79. didTapMarker:(GMSMarker *)marker;
  80. /**
  81. * Called when the panorama tiles for the current view have just been requested
  82. * and are beginning to load.
  83. */
  84. - (void)panoramaViewDidStartRendering:(GMSPanoramaView *)panoramaView;
  85. /**
  86. * Called when the panorama tiles have been loaded (or permanently failed to load)
  87. * and rendered on screen.
  88. */
  89. - (void)panoramaViewDidFinishRendering:(GMSPanoramaView *)panoramaView;
  90. @end
  91. /**
  92. * A panorama is used to display Street View imagery. It should be constructed
  93. * via [[GMSPanoramaView alloc] initWithFrame:], and configured
  94. * post-initialization.
  95. *
  96. * All properties and methods should be accessed on the main thread, similar to
  97. * all UIKit objects. The GMSPanoramaViewDelegate methods will also be called
  98. * back only on the main thread.
  99. *
  100. * The backgroundColor of this view is shown while no panorama is visible, such
  101. * as while it is loading or if the panorama is later set to nil. The alpha
  102. * color of backgroundColor is not supported.
  103. */
  104. @interface GMSPanoramaView : UIView
  105. /**
  106. * The panorama to display; setting it will transition to a new panorama. This
  107. * is animated, except for the initial panorama.
  108. *
  109. * Can be set to nil to clear the view.
  110. */
  111. @property(nonatomic, strong) GMSPanorama *GMS_NULLABLE_PTR panorama;
  112. /** GMSPanoramaView delegate. */
  113. @property(nonatomic, weak) IBOutlet id<GMSPanoramaViewDelegate> GMS_NULLABLE_PTR delegate;
  114. /**
  115. * Sets the preference for whether all gestures should be enabled (default) or
  116. * disabled.
  117. * This does not limit programmatic movement of the camera or control of the
  118. * panorama.
  119. */
  120. - (void)setAllGesturesEnabled:(BOOL)enabled;
  121. /**
  122. * Controls whether orientation gestures are enabled (default) or disabled. If
  123. * enabled, users may use gestures to change the orientation of the camera.
  124. * This does not limit programmatic movement of the camera.
  125. */
  126. @property(nonatomic, assign) BOOL orientationGestures;
  127. /**
  128. * Controls whether zoom gestures are enabled (default) or disabled. If
  129. * enabled, users may pinch to zoom the camera.
  130. * This does not limit programmatic movement of the camera.
  131. */
  132. @property(nonatomic, assign) BOOL zoomGestures;
  133. /**
  134. * Controls whether navigation gestures are enabled (default) or disabled. If
  135. * enabled, users may use a single tap on navigation links or double tap the
  136. * view to change panoramas.
  137. * This does not limit programmatic control of the panorama.
  138. */
  139. @property(nonatomic, assign) BOOL navigationGestures;
  140. /**
  141. * Controls whether the tappable navigation links are hidden or visible
  142. * (default).
  143. * Hidden navigation links cannot be tapped.
  144. */
  145. @property(nonatomic, assign) BOOL navigationLinksHidden;
  146. /**
  147. * Controls whether the street name overlays are hidden or visible (default).
  148. */
  149. @property(nonatomic, assign) BOOL streetNamesHidden;
  150. /**
  151. * Controls the panorama's camera. Setting a new camera here jumps to the new
  152. * camera value, with no animation.
  153. */
  154. @property(nonatomic, strong) GMSPanoramaCamera *camera;
  155. /**
  156. * Accessor for the custom CALayer type used for the layer.
  157. */
  158. @property(nonatomic, readonly, retain) GMSPanoramaLayer *layer;
  159. /**
  160. * Animates the camera of this GMSPanoramaView to |camera|, over |duration|
  161. * (specified in seconds).
  162. */
  163. - (void)animateToCamera:(GMSPanoramaCamera *)camera
  164. animationDuration:(NSTimeInterval)duration;
  165. /**
  166. * Modifies the camera according to |cameraUpdate|, over |duration| (specified
  167. * in seconds).
  168. */
  169. - (void)updateCamera:(GMSPanoramaCameraUpdate *)cameraUpdate
  170. animationDuration:(NSTimeInterval)duration;
  171. /**
  172. * Requests a panorama near |coordinate|.
  173. * Upon successful completion panoramaView:didMoveToPanorama: and
  174. * panoramaView:didMoveToPanorama:nearCoordinate: will be sent to
  175. * GMSPanoramaViewDelegate.
  176. * On error panoramaView:error:onMoveNearCoordinate: will be sent.
  177. * Repeated calls to moveNearCoordinate: result in the previous pending
  178. * (incomplete) transitions being cancelled -- only the most recent of
  179. * moveNearCoordinate: and moveToPanoramaId: will proceed and generate events.
  180. */
  181. - (void)moveNearCoordinate:(CLLocationCoordinate2D)coordinate;
  182. /**
  183. * Similar to moveNearCoordinate: but allows specifying a search radius (meters)
  184. * around |coordinate|.
  185. */
  186. - (void)moveNearCoordinate:(CLLocationCoordinate2D)coordinate
  187. radius:(NSUInteger)radius;
  188. /**
  189. * Requests a panorama with |panoramaID|.
  190. * Upon successful completion panoramaView:didMoveToPanorama: will be sent to
  191. * GMSPanoramaViewDelegate.
  192. * On error panoramaView:error:onMoveToPanoramaID: will be sent.
  193. * Repeated calls to moveToPanoramaID: result in the previous pending
  194. * (incomplete) transitions being cancelled -- only the most recent of
  195. * moveNearCoordinate: and moveToPanoramaId: will proceed and generate events.
  196. * Only panoramaIDs obtained from the Google Maps SDK for iOS are supported.
  197. */
  198. - (void)moveToPanoramaID:(NSString *)panoramaID;
  199. /**
  200. * For the current view, returns the screen point the |orientation| points
  201. * through. This value may be outside the view for forward facing orientations
  202. * which are far enough away from straight ahead.
  203. * The result will contain NaNs for camera orientations which point away from
  204. * the view, where the implied screen point would have had a negative distance
  205. * from the camera in the direction of orientation.
  206. */
  207. - (CGPoint)pointForOrientation:(GMSOrientation)orientation;
  208. /**
  209. * Given a point for this view, returns the current camera orientation pointing
  210. * through that screen location. At the center of this view, the returned
  211. * GMSOrientation will be approximately equal to that of the current
  212. * GMSPanoramaCamera.
  213. */
  214. - (GMSOrientation)orientationForPoint:(CGPoint)point;
  215. /**
  216. * Convenience constructor for GMSPanoramaView, which searches for and displays
  217. * a GMSPanorama near |coordinate|. This performs a similar action to that of
  218. * moveNearCoordinate:, and will call the same delegate methods.
  219. */
  220. + (instancetype)panoramaWithFrame:(CGRect)frame
  221. nearCoordinate:(CLLocationCoordinate2D)coordinate;
  222. /**
  223. * Similar to panoramaWithFrame:nearCoordinate: but allows specifying a
  224. * search radius (meters) around |coordinate|.
  225. */
  226. + (instancetype)panoramaWithFrame:(CGRect)frame
  227. nearCoordinate:(CLLocationCoordinate2D)coordinate
  228. radius:(NSUInteger)radius;
  229. @end
  230. GMS_ASSUME_NONNULL_END