BMKAnnotationView.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * BMKAnnotationView.h
  3. * BMapKit
  4. *
  5. * Copyright 2011 Baidu Inc. All rights reserved.
  6. *
  7. */
  8. #import <UIKit/UIKit.h>
  9. #import "BMKActionPaopaoView.h"
  10. #if __IPHONE_3_2 <= __IPHONE_OS_VERSION_MAX_ALLOWED
  11. enum {
  12. BMKAnnotationViewDragStateNone = 0, ///< 静止状态.
  13. BMKAnnotationViewDragStateStarting, ///< 开始拖动
  14. BMKAnnotationViewDragStateDragging, ///< 拖动中
  15. BMKAnnotationViewDragStateCanceling, ///< 取消拖动
  16. BMKAnnotationViewDragStateEnding ///< 拖动结束
  17. };
  18. typedef NSUInteger BMKAnnotationViewDragState;
  19. #endif
  20. @class BMKAnnotationViewInternal;
  21. @protocol BMKAnnotation;
  22. @class BMKMapView;
  23. @class BMKMapViewInternal;
  24. ///标注view
  25. @interface BMKAnnotationView : UIView
  26. {
  27. @private
  28. BMKAnnotationViewInternal *_internal;
  29. BOOL _enabled3D;
  30. CGPoint _originPt;
  31. CGPoint startPoint;
  32. }
  33. /**
  34. *初始化并返回一个annotation view
  35. *@param annotation 关联的annotation对象
  36. *@param reuseIdentifier 如果要重用view,传入一个字符串,否则设为nil,建议重用view
  37. *@return 初始化成功则返回annotation view,否则返回nil
  38. */
  39. - (id)initWithAnnotation:(id <BMKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier;
  40. ///复用标志
  41. @property (nonatomic, readonly) NSString *reuseIdentifier;
  42. ///paopaoView
  43. @property (nonatomic, strong)BMKActionPaopaoView* paopaoView;
  44. /**
  45. *当view从reuse队列里取出时被调用
  46. *默认不做任何事
  47. */
  48. - (void)prepareForReuse;
  49. ///关联的annotation
  50. @property (nonatomic, strong) id <BMKAnnotation> annotation;
  51. ///annotation view显示的图像
  52. @property (nonatomic, strong) UIImage *image;
  53. ///默认情况下, annotation view的中心位于annotation的坐标位置,可以设置centerOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是像素
  54. @property (nonatomic) CGPoint centerOffset;
  55. ///默认情况下, 弹出的气泡位于view正中上方,可以设置calloutOffset改变view的位置,正的偏移使view朝右下方移动,负的朝左上方,单位是像素
  56. @property (nonatomic) CGPoint calloutOffset;
  57. ///默认情况下,标注没有3D效果,可以设置enabled3D改变使用3D效果,使得标注在地图旋转和俯视时跟随旋转、俯视
  58. @property (nonatomic) BOOL enabled3D;
  59. ///默认为YES,当为NO时view忽略触摸事件
  60. @property (nonatomic, getter=isEnabled) BOOL enabled;
  61. ///默认为NO,当view被点中时被设为YES,用户不要直接设置这个属性.若设置,需要在设置后调用BMKMapView的- (void)mapForceRefresh; 方法刷新地图
  62. @property (nonatomic, getter=isSelected) BOOL selected;
  63. /**
  64. *设定view的选中状态
  65. *该方法被BMKMapView调用
  66. *@param selected 如果view需要显示为选中状态,该值为YES
  67. *@param animated 如果需要动画效果,该值为YES,暂不支持
  68. */
  69. - (void)setSelected:(BOOL)selected animated:(BOOL)animated;
  70. ///当为YES时,view被选中时会弹出气泡,annotation必须实现了title这个方法
  71. @property (nonatomic) BOOL canShowCallout;
  72. ///显示在气泡左侧的view(使用默认气泡时,view的width最大值为32,height最大值为41,大于则使用最大值)
  73. @property (strong, nonatomic) UIView *leftCalloutAccessoryView;
  74. ///显示在气泡右侧的view(使用默认气泡时,view的width最大值为32,height最大值为41,大于则使用最大值)
  75. @property (strong, nonatomic) UIView *rightCalloutAccessoryView;
  76. ///当设为YES并实现了setCoordinate:方法时,支持将view在地图上拖动, ios 3.2以后支持
  77. @property (nonatomic, getter=isDraggable) BOOL draggable __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_2);
  78. ///当前view的拖动状态, ios 3.2以后支持
  79. @property (nonatomic) BMKAnnotationViewDragState dragState __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_2);
  80. @end