Created
November 26, 2010 21:22
-
-
Save zssz/717230 to your computer and use it in GitHub Desktop.
Scrolls the map the point amount specified in offset and optionally animates this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)scrollWithOffset:(CGSize)offset animated:(BOOL)animated | |
{ | |
MKMapPoint centerMapPoint = MKMapPointForCoordinate(self.centerCoordinate); | |
CGPoint centerPoint = [self convertCoordinate:self.centerCoordinate toPointToView:self]; | |
CGPoint destinationPoint = CGPointMake(centerPoint.x+offset.width, centerPoint.y+offset.height); | |
CLLocationCoordinate2D destinationCoordinate = [self convertPoint:destinationPoint toCoordinateFromView:self]; | |
MKMapPoint destMapPoint = MKMapPointForCoordinate(destinationCoordinate); | |
MKMapRect mapRect = self.visibleMapRect; | |
mapRect = MKMapRectOffset(mapRect, centerMapPoint.x-destMapPoint.x, centerMapPoint.y-destMapPoint.y); | |
[self setVisibleMapRect:mapRect animated:animated]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment