Authored by Thomas Rasch

o Fixes, improvements

@@ -116,11 +116,12 @@ @@ -116,11 +116,12 @@
116 116
117 - (void)setLayer:(RMMapLayer *)aLayer 117 - (void)setLayer:(RMMapLayer *)aLayer
118 { 118 {
119 - if (layer == aLayer) return;  
120 - [layer removeFromSuperlayer]; [layer release];  
121 - layer = [aLayer retain]; 119 + if (layer != aLayer) {
  120 + [layer removeFromSuperlayer]; [layer release];
  121 + layer = [aLayer retain];
  122 + layer.annotation = self;
  123 + }
122 layer.position = self.position; 124 layer.position = self.position;
123 - layer.annotation = self;  
124 } 125 }
125 126
126 - (BOOL)isAnnotationWithinBounds:(CGRect)bounds 127 - (BOOL)isAnnotationWithinBounds:(CGRect)bounds
@@ -139,4 +140,12 @@ @@ -139,4 +140,12 @@
139 return [self isAnnotationWithinBounds:screenBounds]; 140 return [self isAnnotationWithinBounds:screenBounds];
140 } 141 }
141 142
  143 +- (NSString *)description
  144 +{
  145 + if (self.hasBoundingBox)
  146 + return [NSString stringWithFormat:@"<%@: %@ @ (%.0f,%.0f) {(%.0f,%.0f) - (%.0f,%.0f)}>", NSStringFromClass([self class]), self.title, self.projectedLocation.easting, self.projectedLocation.northing, self.projectedBoundingBox.origin.easting, self.projectedBoundingBox.origin.northing, self.projectedBoundingBox.origin.easting + self.projectedBoundingBox.size.width, self.projectedBoundingBox.origin.northing + self.projectedBoundingBox.size.height];
  147 + else
  148 + return [NSString stringWithFormat:@"<%@: %@ @ (%.0f,%.0f)>", NSStringFromClass([self class]), self.title, self.projectedLocation.easting, self.projectedLocation.northing];
  149 +}
  150 +
142 @end 151 @end
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 return self; 58 return self;
59 } 59 }
60 60
61 -/// \bug why return nil for the "position" and "bounds" actionForKey? Does this do anything besides block Core Animation? 61 +/// return nil for certain animation keys to block core animation
62 - (id <CAAction>)actionForKey:(NSString *)key 62 - (id <CAAction>)actionForKey:(NSString *)key
63 { 63 {
64 if ([key isEqualToString:@"position"] || [key isEqualToString:@"bounds"]) 64 if ([key isEqualToString:@"position"] || [key isEqualToString:@"bounds"])
@@ -52,9 +52,9 @@ @@ -52,9 +52,9 @@
52 52
53 #pragma mark --- begin constants ---- 53 #pragma mark --- begin constants ----
54 54
55 -#define kDefaultDecelerationFactor .88f 55 +#define kDefaultDecelerationFactor .80f
56 #define kMinDecelerationDelta 0.6f 56 #define kMinDecelerationDelta 0.6f
57 -#define kDecelerationTimerInterval 0.02f 57 +#define kDecelerationTimerInterval 0.04f
58 58
59 #define kZoomAnimationStepTime 0.03f 59 #define kZoomAnimationStepTime 0.03f
60 #define kZoomAnimationAnimationTime 0.1f 60 #define kZoomAnimationAnimationTime 0.1f
@@ -420,10 +420,10 @@ @@ -420,10 +420,10 @@
420 if (![self tileSourceBoundsContainProjectedPoint:projectedCenter]) 420 if (![self tileSourceBoundsContainProjectedPoint:projectedCenter])
421 return; 421 return;
422 422
423 - [mercatorToScreenProjection moveScreenBy:delta];  
424 - [imagesOnScreen moveBy:delta];  
425 - [tileLoader moveBy:delta];  
426 - [self correctPositionOfAllAnnotationsIncludingInvisibles:correctAllSublayers]; 423 + [mercatorToScreenProjection moveScreenBy:delta];
  424 + [imagesOnScreen moveBy:delta];
  425 + [tileLoader moveBy:delta];
  426 + [self correctPositionOfAllAnnotationsIncludingInvisibles:correctAllSublayers];
427 } 427 }
428 428
429 - (void)moveToCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated 429 - (void)moveToCoordinate:(CLLocationCoordinate2D)coordinate animated:(BOOL)animated
@@ -1088,9 +1088,8 @@ @@ -1088,9 +1088,8 @@
1088 return; 1088 return;
1089 1089
1090 [mercatorToScreenProjection setProjectedCenter:projectedPoint]; 1090 [mercatorToScreenProjection setProjectedCenter:projectedPoint];
1091 - [self correctPositionOfAllAnnotations];  
1092 [tileLoader reload]; 1091 [tileLoader reload];
1093 - [overlay setNeedsDisplay]; 1092 + [self correctPositionOfAllAnnotations];
1094 } 1093 }
1095 1094
1096 - (RMProjectedRect)projectedBounds 1095 - (RMProjectedRect)projectedBounds
@@ -1101,6 +1100,8 @@ @@ -1101,6 +1100,8 @@
1101 - (void)setProjectedBounds:(RMProjectedRect)boundsRect 1100 - (void)setProjectedBounds:(RMProjectedRect)boundsRect
1102 { 1101 {
1103 [mercatorToScreenProjection setProjectedBounds:boundsRect]; 1102 [mercatorToScreenProjection setProjectedBounds:boundsRect];
  1103 + [tileLoader reload];
  1104 + [self correctPositionOfAllAnnotations];
1104 } 1105 }
1105 1106
1106 - (RMTileRect)tileBounds 1107 - (RMTileRect)tileBounds
@@ -1308,6 +1309,10 @@ @@ -1308,6 +1309,10 @@
1308 CGRect screenBounds = [[self mercatorToScreenProjection] screenBounds]; 1309 CGRect screenBounds = [[self mercatorToScreenProjection] screenBounds];
1309 CALayer *lastLayer = nil; 1310 CALayer *lastLayer = nil;
1310 1311
  1312 + // Prevent blurry movements
  1313 + [CATransaction begin];
  1314 + [CATransaction setAnimationDuration:0];
  1315 +
1311 @synchronized (annotations) 1316 @synchronized (annotations)
1312 { 1317 {
1313 if (correctAllAnnotations) 1318 if (correctAllAnnotations)
@@ -1329,21 +1334,23 @@ @@ -1329,21 +1334,23 @@
1329 1334
1330 [visibleAnnotations addObject:annotation]; 1335 [visibleAnnotations addObject:annotation];
1331 } 1336 }
  1337 + lastLayer = annotation.layer;
1332 } else { 1338 } else {
1333 annotation.layer = nil; 1339 annotation.layer = nil;
1334 [visibleAnnotations removeObject:annotation]; 1340 [visibleAnnotations removeObject:annotation];
1335 } 1341 }
1336 - lastLayer = annotation.layer;  
1337 } 1342 }
1338 - RMLog(@"%d annotations on screen, %d total", [[overlay sublayers] count], [annotations count]); 1343 +// RMLog(@"%d annotations on screen, %d total", [[overlay sublayers] count], [annotations count]);
1339 } else { 1344 } else {
1340 for (RMAnnotation *annotation in visibleAnnotations) 1345 for (RMAnnotation *annotation in visibleAnnotations)
1341 { 1346 {
1342 [self correctScreenPosition:annotation]; 1347 [self correctScreenPosition:annotation];
1343 } 1348 }
1344 - RMLog(@"%d annotations corrected", [visibleAnnotations count]); 1349 +// RMLog(@"%d annotations corrected", [visibleAnnotations count]);
1345 } 1350 }
1346 } 1351 }
  1352 +
  1353 + [CATransaction commit];
1347 } 1354 }
1348 1355
1349 - (void)correctPositionOfAllAnnotations 1356 - (void)correctPositionOfAllAnnotations
@@ -242,7 +242,7 @@ @@ -242,7 +242,7 @@
242 if (!scaleLineWidth) { 242 if (!scaleLineWidth) {
243 scaledLineWidth *= renderedScale; 243 scaledLineWidth *= renderedScale;
244 } 244 }
245 - //NSLog(@"line width = %f, content scale = %f", scaledLineWidth, renderedScale); 245 + // NSLog(@"line width = %f, content scale = %f", scaledLineWidth, renderedScale);
246 246
247 if (!scaleLineDash && _lineDashLengths) { 247 if (!scaleLineDash && _lineDashLengths) {
248 dashLengths = _scaledLineDashLengths; 248 dashLengths = _scaledLineDashLengths;