Authored by Thomas Rasch

o Bugfix: adjustTilesForRetinaDisplay didn't work anymore

... ... @@ -94,7 +94,7 @@
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (zoom == (short)ceilf(mapView.zoom))
if (zoom == (short)ceilf(mapView.adjustedZoomForRetinaDisplay))
{
int x = floor(rect.origin.x / rect.size.width),
y = floor(fabs(rect.origin.y / rect.size.height));
... ... @@ -110,7 +110,7 @@
}
else // Probably due to renderInContext:
{
zoom = (short)ceilf(mapView.zoom);
zoom = (short)ceilf(mapView.adjustedZoomForRetinaDisplay);
CGFloat rectSize = bounds.size.width / powf(2.0, (float)zoom);
int x1 = floor(rect.origin.x / rectSize),
... ...
... ... @@ -115,7 +115,8 @@ typedef enum {
@property (nonatomic, readonly) float screenScale;
@property (nonatomic, assign) NSUInteger boundingMask;
@property (nonatomic, assign) BOOL adjustTilesForRetinaDisplay;
@property (nonatomic, assign) BOOL adjustTilesForRetinaDisplay;
@property (nonatomic, readonly) float adjustedZoomForRetinaDisplay; // takes adjustTilesForRetinaDisplay and screen scale into account
@property (nonatomic, assign) float zoom; /// zoom level is clamped to range (minZoom, maxZoom)
@property (nonatomic, assign) float minZoom;
... ...
... ... @@ -136,11 +136,7 @@
tiledLayerView = nil;
overlayView = nil;
screenScale = 1.0;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
{
screenScale = [[[UIScreen mainScreen] valueForKey:@"scale"] floatValue];
}
screenScale = [UIScreen mainScreen].scale;
boundingMask = RMMapMinWidthBound;
adjustTilesForRetinaDisplay = NO;
... ... @@ -1404,6 +1400,14 @@
[self setCenterCoordinate:self.centerCoordinate animated:NO];
}
- (float)adjustedZoomForRetinaDisplay
{
if (!self.adjustTilesForRetinaDisplay && screenScale > 1.0)
return [self zoom] + 1.0;
return [self zoom];
}
- (RMProjection *)projection
{
return [[projection retain] autorelease];
... ...
... ... @@ -15,32 +15,33 @@
- (void)viewDidLoad
{
NSLog(@"viewDidLoad");
NSLog(@"viewDidLoad");
[super viewDidLoad];
CLLocationCoordinate2D firstLocation;
firstLocation.latitude = 51.2795;
firstLocation.longitude = 1.082;
CLLocationCoordinate2D firstLocation;
firstLocation.latitude = 51.2795;
firstLocation.longitude = 1.082;
self.mapView = [[[RMMapView alloc] initWithFrame:CGRectMake(10, 20, 300, 340)] autorelease];
[mapView setBackgroundColor:[UIColor greenColor]];
[[self view] addSubview:mapView];
[[self view] sendSubviewToBack:mapView];
self.mapView = [[[RMMapView alloc] initWithFrame:CGRectMake(10, 20, 300, 340)] autorelease];
self.mapView.adjustTilesForRetinaDisplay = NO;
[self.mapView setBackgroundColor:[UIColor greenColor]];
[[self view] addSubview:mapView];
[[self view] sendSubviewToBack:mapView];
}
- (void)dealloc
{
[mapView removeFromSuperview];
self.mapView = nil;
[super dealloc];
self.mapView = nil;
[super dealloc];
}
- (IBAction)doTheTest:(id)sender
{
CLLocationCoordinate2D secondLocation;
secondLocation.latitude = -43.63;
secondLocation.longitude = 172.66;
[self.mapView setCenterCoordinate:secondLocation];
CLLocationCoordinate2D secondLocation;
secondLocation.latitude = -43.50;
secondLocation.longitude = 172.56;
[self.mapView setCenterCoordinate:secondLocation];
}
- (IBAction)takeSnapshot:(id)sender
... ...