Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)zoomInGesture:(UITapGestureRecognizer *) recognizer {
  2.     currentRegion = self.mapView.region;
  3.     currentSpan = self.mapView.region.span;
  4.     isZoomingWithDoubleTap = YES;
  5.    
  6.     MKCoordinateRegion region = currentRegion;
  7.     MKCoordinateSpan span = currentSpan;
  8.    
  9.     span.latitudeDelta = currentSpan.latitudeDelta / 2.3;
  10.     span.longitudeDelta = currentSpan.longitudeDelta / 2.3;
  11.     region.span = span;
  12.    
  13.     [self.mapView setRegion:region animated:YES];
  14. }
  15.  
  16. - (void)pinchOnMap:(UIPinchGestureRecognizer *) recognizer {
  17.    
  18.     if (self.mapView.region.span.latitudeDelta < 0.18) {
  19.    
  20.     if (recognizer.state == UIGestureRecognizerStateBegan) {
  21.         currentRegion = self.mapView.region;
  22.         currentSpan = self.mapView.region.span;
  23.     }
  24.    
  25.     if (recognizer.state == UIGestureRecognizerStateChanged) {
  26.             MKCoordinateRegion region = currentRegion;
  27.             MKCoordinateSpan span = currentSpan;
  28.             span.latitudeDelta = currentSpan.latitudeDelta / recognizer.scale;
  29.             span.longitudeDelta = currentSpan.longitudeDelta / recognizer.scale;
  30.             region.span = span;
  31.             [self.mapView setRegion:region animated:NO];
  32.     }
  33.     }
  34.     else {
  35.         CLLocationCoordinate2D coordinate = [self.mapView.userLocation coordinate];
  36.         MKCoordinateRegion region;
  37.         region.center = coordinate;
  38.         MKCoordinateSpan span;
  39.         span.latitudeDelta = 0.1;
  40.         span.longitudeDelta = 0.1;
  41.         region.span = span;
  42.        
  43.         [self.mapView setRegion:region animated:YES];
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement