GMSMarker.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. //
  2. // GMSMarker.h
  3. // Google Maps SDK for iOS
  4. //
  5. // Copyright 2012 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 <GoogleMaps/GMSOverlay.h>
  11. #if __has_feature(modules)
  12. @import GoogleMapsBase;
  13. #else
  14. #import <GoogleMapsBase/GoogleMapsBase.h>
  15. #endif
  16. @class GMSMarkerLayer;
  17. @class GMSPanoramaView;
  18. @class UIImage;
  19. GMS_ASSUME_NONNULL_BEGIN
  20. /**
  21. * Animation types for GMSMarker.
  22. */
  23. typedef enum {
  24. /** No animation (default). */
  25. kGMSMarkerAnimationNone = 0,
  26. /** The marker will pop from its groundAnchor when added. */
  27. kGMSMarkerAnimationPop,
  28. } GMSMarkerAnimation;
  29. /**
  30. * A marker is an icon placed at a particular point on the map's surface. A
  31. * marker's icon is drawn oriented against the device's screen rather than the
  32. * map's surface; i.e., it will not necessarily change orientation due to map
  33. * rotations, tilting, or zooming.
  34. */
  35. @interface GMSMarker : GMSOverlay
  36. /** Marker position. Animated. */
  37. @property(nonatomic, assign) CLLocationCoordinate2D position;
  38. /** Snippet text, shown beneath the title in the info window when selected. */
  39. @property(nonatomic, copy) NSString *GMS_NULLABLE_PTR snippet;
  40. /**
  41. * Marker icon to render. If left nil, uses a default SDK place marker.
  42. *
  43. * Supports animated images, but each frame must be the same size or the
  44. * behavior is undefined.
  45. *
  46. * Supports the use of alignmentRectInsets to specify a reduced tap area. This
  47. * also redefines how anchors are specified. For an animated image the
  48. * value for the animation is used, not the individual frames.
  49. */
  50. @property(nonatomic, strong) UIImage *GMS_NULLABLE_PTR icon;
  51. /**
  52. * Marker view to render. If left nil, falls back to the |icon| property instead.
  53. *
  54. * Supports animation of all animatable properties of UIView, except |frame| and |center|. Changing
  55. * these properties or their corresponding CALayer version, including |position|, is not supported.
  56. *
  57. * Note that the view behaves as if |clipsToBounds| is set to YES, regardless of its actual
  58. * value.
  59. */
  60. @property(nonatomic, strong) UIView *iconView;
  61. /**
  62. * Controls whether the icon for this marker should be redrawn every frame.
  63. *
  64. * Note that when this changes from NO to YES, the icon is guaranteed to be redrawn next frame.
  65. *
  66. * Defaults to YES.
  67. * Has no effect if |iconView| is nil.
  68. */
  69. @property(nonatomic, assign) BOOL tracksViewChanges;
  70. /**
  71. * Controls whether the info window for this marker should be redrawn every frame.
  72. *
  73. * Note that when this changes from NO to YES, the info window is guaranteed to be redrawn next
  74. * frame.
  75. *
  76. * Defaults to NO.
  77. */
  78. @property(nonatomic, assign) BOOL tracksInfoWindowChanges;
  79. /**
  80. * The ground anchor specifies the point in the icon image that is anchored to
  81. * the marker's position on the Earth's surface. This point is specified within
  82. * the continuous space [0.0, 1.0] x [0.0, 1.0], where (0,0) is the top-left
  83. * corner of the image, and (1,1) is the bottom-right corner.
  84. *
  85. * If the image has non-zero alignmentRectInsets, the top-left and bottom-right
  86. * mentioned above refer to the inset section of the image.
  87. */
  88. @property(nonatomic, assign) CGPoint groundAnchor;
  89. /**
  90. * The info window anchor specifies the point in the icon image at which to
  91. * anchor the info window, which will be displayed directly above this point.
  92. * This point is specified within the same space as groundAnchor.
  93. */
  94. @property(nonatomic, assign) CGPoint infoWindowAnchor;
  95. /**
  96. * Controls the animation used when this marker is placed on a GMSMapView
  97. * (default kGMSMarkerAnimationNone, no animation).
  98. */
  99. @property(nonatomic, assign) GMSMarkerAnimation appearAnimation;
  100. /**
  101. * Controls whether this marker can be dragged interactively (default NO).
  102. */
  103. @property(nonatomic, assign, getter=isDraggable) BOOL draggable;
  104. /**
  105. * Controls whether this marker should be flat against the Earth's surface (YES)
  106. * or a billboard facing the camera (NO, default).
  107. */
  108. @property(nonatomic, assign, getter=isFlat) BOOL flat;
  109. /**
  110. * Sets the rotation of the marker in degrees clockwise about the marker's
  111. * anchor point. The axis of rotation is perpendicular to the marker. A rotation
  112. * of 0 corresponds to the default position of the marker. Animated.
  113. *
  114. * When the marker is flat on the map, the default position is north aligned and
  115. * the rotation is such that the marker always remains flat on the map. When the
  116. * marker is a billboard, the default position is pointing up and the rotation
  117. * is such that the marker is always facing the camera.
  118. */
  119. @property(nonatomic, assign) CLLocationDegrees rotation;
  120. /**
  121. * Sets the opacity of the marker, between 0 (completely transparent) and 1
  122. * (default) inclusive.
  123. */
  124. @property(nonatomic, assign) float opacity;
  125. /**
  126. * Marker data. You can use this property to associate an arbitrary object with
  127. * this marker. Google Maps SDK for iOS neither reads nor writes this property.
  128. *
  129. * Note that userData should not hold any strong references to any Maps
  130. * objects, otherwise a loop may be created (preventing ARC from releasing
  131. * objects).
  132. */
  133. @property(nonatomic, strong) id GMS_NULLABLE_PTR userData;
  134. /**
  135. * Provides the Core Animation layer for this GMSMarker.
  136. */
  137. @property(nonatomic, strong, readonly) GMSMarkerLayer *layer;
  138. /**
  139. * The |panoramaView| specifies which panorama view will attempt to show this
  140. * marker. Note that if the marker's |position| is too far away from the
  141. * |panoramaView|'s current panorama location, it will not be displayed as it
  142. * will be too small.
  143. * Can be set to nil to remove the marker from any current panorama view it
  144. * is attached to.
  145. * A marker can be shown on both a panorama and a map at the same time.
  146. */
  147. @property(nonatomic, weak) GMSPanoramaView *GMS_NULLABLE_PTR panoramaView;
  148. /** Convenience constructor for a default marker. */
  149. + (instancetype)markerWithPosition:(CLLocationCoordinate2D)position;
  150. /** Creates a tinted version of the default marker image for use as an icon. */
  151. + (UIImage *)markerImageWithColor:(UIColor *GMS_NULLABLE_PTR)color;
  152. @end
  153. /**
  154. * The default position of the ground anchor of a GMSMarker: the center bottom
  155. * point of the marker icon.
  156. */
  157. FOUNDATION_EXTERN const CGPoint kGMSMarkerDefaultGroundAnchor;
  158. /**
  159. * The default position of the info window anchor of a GMSMarker: the center top
  160. * point of the marker icon.
  161. */
  162. FOUNDATION_EXTERN const CGPoint kGMSMarkerDefaultInfoWindowAnchor;
  163. GMS_ASSUME_NONNULL_END