|
@@ -23,6 +23,7 @@ typedef enum {
|
|
|
|
|
|
|
|
@property (nonatomic,assign) AMShipAnnotationPriority priority;
|
|
@property (nonatomic,assign) AMShipAnnotationPriority priority;
|
|
|
@property (nonatomic,copy) NSString *imageName;
|
|
@property (nonatomic,copy) NSString *imageName;
|
|
|
|
|
+@property (nonatomic,assign) BOOL isCurrent;
|
|
|
|
|
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
@@ -31,7 +32,11 @@ typedef enum {
|
|
|
@end
|
|
@end
|
|
|
|
|
|
|
|
@interface AMShipMap () <MKMapViewDelegate>
|
|
@interface AMShipMap () <MKMapViewDelegate>
|
|
|
-
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ MKAnnotationView *_currentAnnotaion;
|
|
|
|
|
+ NSTimer *_twinkleTimer;
|
|
|
|
|
+ float _timerAngle;
|
|
|
|
|
+}
|
|
|
@property (nonatomic,strong) AMMapView *mapView;
|
|
@property (nonatomic,strong) AMMapView *mapView;
|
|
|
@property (nonatomic,strong) UIButton *resizeBtn;
|
|
@property (nonatomic,strong) UIButton *resizeBtn;
|
|
|
|
|
|
|
@@ -71,6 +76,10 @@ typedef enum {
|
|
|
ann.priority = priority;
|
|
ann.priority = priority;
|
|
|
ann.imageName = imgName;
|
|
ann.imageName = imgName;
|
|
|
|
|
|
|
|
|
|
+ if ([port isEqualToString:@"Current"]) {
|
|
|
|
|
+ ann.isCurrent = YES;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 将大头针数据模型添加到MKMapView上管理
|
|
// 将大头针数据模型添加到MKMapView上管理
|
|
|
[self.mapView addAnnotation:ann];
|
|
[self.mapView addAnnotation:ann];
|
|
|
|
|
|
|
@@ -157,6 +166,7 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
if (current && self.showCurrent) {
|
|
if (current && self.showCurrent) {
|
|
|
[self moveToLocation:current];
|
|
[self moveToLocation:current];
|
|
|
|
|
+
|
|
|
} else if (pol && self.showPol) {
|
|
} else if (pol && self.showPol) {
|
|
|
[self moveToLocation:pol];
|
|
[self moveToLocation:pol];
|
|
|
} else if (pod && self.showPod) {
|
|
} else if (pod && self.showPod) {
|
|
@@ -165,6 +175,61 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+#pragma mark - Twinkle Current
|
|
|
|
|
+
|
|
|
|
|
+- (void)startTwinkle {
|
|
|
|
|
+ if (_twinkleTimer) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
|
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
|
|
|
|
+ if (weakSelf) {
|
|
|
|
|
+ __strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
|
|
+ strongSelf->_twinkleTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(twinkleTimerExecute:) userInfo:nil repeats:YES];
|
|
|
|
|
+ [[NSRunLoop currentRunLoop] addTimer:strongSelf->_twinkleTimer forMode:NSDefaultRunLoopMode];
|
|
|
|
|
+ [[NSRunLoop currentRunLoop] run];
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)twinkleTimerExecute:(NSTimer *)timer {
|
|
|
|
|
+ if (!_currentAnnotaion) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
+ if (weakSelf) {
|
|
|
|
|
+ __strong typeof(weakSelf) strongSelf = weakSelf;
|
|
|
|
|
+
|
|
|
|
|
+ strongSelf->_timerAngle += 0.1;
|
|
|
|
|
+ if (strongSelf->_timerAngle == 3.1) {
|
|
|
|
|
+ strongSelf->_timerAngle = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ float alpha = ABS(cos(strongSelf->_timerAngle));
|
|
|
|
|
+ strongSelf->_currentAnnotaion.alpha = alpha;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)stopTwinkle {
|
|
|
|
|
+ if (_twinkleTimer) {
|
|
|
|
|
+ [_twinkleTimer invalidate];
|
|
|
|
|
+ _twinkleTimer = nil;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+#pragma mark - Apear
|
|
|
|
|
+
|
|
|
|
|
+- (void)shipMapWillAppear {
|
|
|
|
|
+ if (self.twinkleCurrent) {
|
|
|
|
|
+ [self startTwinkle];
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+- (void)shipMapWillDisappear {
|
|
|
|
|
+ [self stopTwinkle];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
#pragma mark - Map Delegate
|
|
#pragma mark - Map Delegate
|
|
|
|
|
|
|
|
// 当地图上添加了标注以后要执行的回调方法
|
|
// 当地图上添加了标注以后要执行的回调方法
|
|
@@ -196,6 +261,10 @@ typedef enum {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (shipAnnotation.isCurrent) {
|
|
|
|
|
+ _currentAnnotaion = pinView;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return pinView;
|
|
return pinView;
|
|
|
} else {
|
|
} else {
|
|
|
return nil;
|
|
return nil;
|
|
@@ -223,6 +292,11 @@ typedef enum {
|
|
|
|
|
|
|
|
#pragma mark - Life
|
|
#pragma mark - Life
|
|
|
|
|
|
|
|
|
|
+- (void)dealloc {
|
|
|
|
|
+
|
|
|
|
|
+ [self stopTwinkle];
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
- (void)setup {
|
|
- (void)setup {
|
|
|
|
|
|
|
|
[self setupMap];
|
|
[self setupMap];
|
|
@@ -258,6 +332,7 @@ typedef enum {
|
|
|
self.showPod = YES;
|
|
self.showPod = YES;
|
|
|
self.showCurrent = YES;
|
|
self.showCurrent = YES;
|
|
|
self.showZoomControl = YES;
|
|
self.showZoomControl = YES;
|
|
|
|
|
+ self.twinkleCurrent = YES;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- (void)setupMap {
|
|
- (void)setupMap {
|