MAAnnotationView.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // MAAnnotationView.h
  3. // MAMapKitDemo
  4. //
  5. // Created by songjian on 13-1-7.
  6. // Copyright © 2016 Amap. All rights reserved.
  7. //
  8. #import "MAConfig.h"
  9. #import <UIKit/UIKit.h>
  10. #import "MACustomCalloutView.h"
  11. ///MAAnnotationView拖动状态
  12. typedef NS_ENUM(NSInteger, MAAnnotationViewDragState)
  13. {
  14. MAAnnotationViewDragStateNone = 0, ///< 静止状态
  15. MAAnnotationViewDragStateStarting, ///< 开始拖动
  16. MAAnnotationViewDragStateDragging, ///< 拖动中
  17. MAAnnotationViewDragStateCanceling, ///< 取消拖动
  18. MAAnnotationViewDragStateEnding ///< 拖动结束
  19. };
  20. @protocol MAAnnotation;
  21. ///标注view
  22. @interface MAAnnotationView : UIView
  23. ///复用标识
  24. @property (nonatomic, readonly, copy) NSString *reuseIdentifier;
  25. ///z值,大值在上,默认为0。类似CALayer的zPosition。zIndex属性只有在viewForAnnotation或者didAddAnnotationViews回调中设置有效。
  26. @property (nonatomic, assign) NSInteger zIndex;
  27. ///关联的annotation
  28. @property (nonatomic, strong) id <MAAnnotation> annotation;
  29. ///显示的image
  30. @property (nonatomic, strong) UIImage *image;
  31. ///image所对应的UIImageView since 5.0.0
  32. @property (nonatomic, strong, readonly) UIImageView *imageView;
  33. ///自定制弹出框view, 用于替换默认弹出框. 注意:此弹出框不会触发-(void)mapView: didAnnotationViewCalloutTapped: since 5.0.0
  34. @property (nonatomic, strong) MACustomCalloutView *customCalloutView;
  35. ///annotationView的中心默认位于annotation的坐标位置,可以设置centerOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是屏幕坐标
  36. @property (nonatomic) CGPoint centerOffset;
  37. ///弹出框默认位于view正中上方,可以设置calloutOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是屏幕坐标
  38. @property (nonatomic) CGPoint calloutOffset;
  39. ///默认为YES,当为NO时view忽略触摸事件
  40. @property (nonatomic, getter=isEnabled) BOOL enabled;
  41. ///是否高亮
  42. @property (nonatomic, getter=isHighlighted) BOOL highlighted;
  43. ///设置是否处于选中状态, 外部如果要选中请使用mapView的selectAnnotation方法
  44. @property (nonatomic, getter=isSelected) BOOL selected;
  45. ///是否允许弹出callout
  46. @property (nonatomic) BOOL canShowCallout;
  47. ///显示在默认弹出框左侧的view
  48. @property (nonatomic, strong) UIView *leftCalloutAccessoryView;
  49. ///显示在默认弹出框右侧的view
  50. @property (nonatomic, strong) UIView *rightCalloutAccessoryView;
  51. ///是否支持拖动
  52. @property (nonatomic, getter=isDraggable) BOOL draggable;
  53. ///当前view的拖动状态
  54. @property (nonatomic) MAAnnotationViewDragState dragState;
  55. /**
  56. * @brief 设置是否处于选中状态, 外部如果要选中请使用mapView的selectAnnotation方法
  57. * @param selected 是否选中
  58. * @param animated 是否使用动画效果
  59. */
  60. - (void)setSelected:(BOOL)selected animated:(BOOL)animated;
  61. /**
  62. * @brief 初始化并返回一个annotation view
  63. * @param annotation 关联的annotation对象
  64. * @param reuseIdentifier 如果要重用view,传入一个字符串,否则设为nil,建议重用view
  65. * @return 初始化成功则返回annotation view,否则返回nil
  66. */
  67. - (id)initWithAnnotation:(id <MAAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier;
  68. /**
  69. * @brief 当从reuse队列里取出时被调用, 子类重新必须调用super
  70. */
  71. - (void)prepareForReuse;
  72. /**
  73. * @brief 设置view的拖动状态
  74. * @param newDragState 新的拖动状态
  75. * @param animated 是否使用动画动画
  76. */
  77. - (void)setDragState:(MAAnnotationViewDragState)newDragState animated:(BOOL)animated;
  78. @end