Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSMutableArray *_bubbleScreenAnimations;
- - (void)selectAnnotation:(EBXPointAnnotation *)annotation {
- // self.bubbleView.scrollEnabled = NO;
- [self.bubbleView hide];
- self.scrolling = YES;
- self.mapView.userInteractionEnabled = NO;
- [self updateAnnotationForEvent:self.selectedEvent];
- //Giving time to update annotations
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- dispatch_async(dispatch_get_main_queue(), ^{
- MKAnnotationView *view = [self.mapView viewForAnnotation:annotation];
- self.annotationView = view;
- view.image = [UIImage imageNamed:@"emptyYellowAnnotation"];
- annotation.selected = YES;
- MKMapRect r = [self.mapView visibleMapRect];
- MKMapPoint pt = MKMapPointForCoordinate([annotation coordinate]);
- r.origin.x = pt.x - r.size.width * 0.5;
- double yRatio = 392.0 / self.mapView.frame.size.height;
- // r.origin.y = pt.y - r.size.height * 0.74409;
- r.origin.y = pt.y - r.size.height * yRatio;
- CGFloat epsilon = 1e-01;
- BOOL xEqual = r.origin.x < [self.mapView visibleMapRect].origin.x + epsilon &&
- r.origin.x > [self.mapView visibleMapRect].origin.x - epsilon;
- BOOL yEqual = r.origin.y < [self.mapView visibleMapRect].origin.y + epsilon &&
- r.origin.y > [self.mapView visibleMapRect].origin.y - epsilon;
- if (xEqual && yEqual) {
- [self.mapView setVisibleMapRect:r animated:NO];
- [self presentBubbleScreenAnimation];
- }
- else {
- if (!_bubbleScreenAnimations) {
- _bubbleScreenAnimations = [NSMutableArray array];
- }
- [_bubbleScreenAnimations addObject:[NSObject new]];
- [self.mapView setVisibleMapRect:r animated:YES];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- if ([_bubbleScreenAnimations count] <= 1) {
- [self presentBubbleScreenAnimation];
- }
- [_bubbleScreenAnimations removeLastObject];
- });
- // [UIView animateWithDuration:0.6 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
- // [self.mapView setVisibleMapRect:r];
- // } completion:^(BOOL finished) {
- // if (finished) {
- // [self presentBubbleScreenAnimation];
- // }
- // }];
- }
- });
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement