refs #109: auto-update coordinate/bbox for shape annotations
Showing
1 changed file
with
19 additions
and
0 deletions
@@ -42,6 +42,8 @@ | @@ -42,6 +42,8 @@ | ||
42 | CAShapeLayer *shapeLayer; | 42 | CAShapeLayer *shapeLayer; |
43 | UIBezierPath *bezierPath; | 43 | UIBezierPath *bezierPath; |
44 | 44 | ||
45 | + NSMutableArray *points; | ||
46 | + | ||
45 | RMMapView *mapView; | 47 | RMMapView *mapView; |
46 | } | 48 | } |
47 | 49 | ||
@@ -89,6 +91,8 @@ | @@ -89,6 +91,8 @@ | ||
89 | scaleLineDash = NO; | 91 | scaleLineDash = NO; |
90 | isFirstPoint = YES; | 92 | isFirstPoint = YES; |
91 | 93 | ||
94 | + points = [[NSMutableArray array] retain]; | ||
95 | + | ||
92 | [(id)self setValue:[[UIScreen mainScreen] valueForKey:@"scale"] forKey:@"contentsScale"]; | 96 | [(id)self setValue:[[UIScreen mainScreen] valueForKey:@"scale"] forKey:@"contentsScale"]; |
93 | 97 | ||
94 | return self; | 98 | return self; |
@@ -99,6 +103,7 @@ | @@ -99,6 +103,7 @@ | ||
99 | mapView = nil; | 103 | mapView = nil; |
100 | [bezierPath release]; bezierPath = nil; | 104 | [bezierPath release]; bezierPath = nil; |
101 | [shapeLayer release]; shapeLayer = nil; | 105 | [shapeLayer release]; shapeLayer = nil; |
106 | + [points release]; points = nil; | ||
102 | [super dealloc]; | 107 | [super dealloc]; |
103 | } | 108 | } |
104 | 109 | ||
@@ -273,12 +278,20 @@ | @@ -273,12 +278,20 @@ | ||
273 | } | 278 | } |
274 | 279 | ||
275 | self.anchorPoint = clippedAnchorPoint; | 280 | self.anchorPoint = clippedAnchorPoint; |
281 | + | ||
282 | + if (self.annotation && [points count]) | ||
283 | + { | ||
284 | + self.annotation.coordinate = ((CLLocation *)[points objectAtIndex:0]).coordinate; | ||
285 | + [self.annotation setBoundingBoxFromLocations:points]; | ||
286 | + } | ||
276 | } | 287 | } |
277 | 288 | ||
278 | #pragma mark - | 289 | #pragma mark - |
279 | 290 | ||
280 | - (void)addPointToProjectedPoint:(RMProjectedPoint)point withDrawing:(BOOL)isDrawing | 291 | - (void)addPointToProjectedPoint:(RMProjectedPoint)point withDrawing:(BOOL)isDrawing |
281 | { | 292 | { |
293 | + [points addObject:[[[CLLocation alloc] initWithLatitude:[mapView projectedPointToCoordinate:point].latitude longitude:[mapView projectedPointToCoordinate:point].longitude] autorelease]]; | ||
294 | + | ||
282 | if (isFirstPoint) | 295 | if (isFirstPoint) |
283 | { | 296 | { |
284 | isFirstPoint = FALSE; | 297 | isFirstPoint = FALSE; |
@@ -481,4 +494,10 @@ | @@ -481,4 +494,10 @@ | ||
481 | [self recalculateGeometryAnimated:animated]; | 494 | [self recalculateGeometryAnimated:animated]; |
482 | } | 495 | } |
483 | 496 | ||
497 | +- (void)setAnnotation:(RMAnnotation *)newAnnotation | ||
498 | +{ | ||
499 | + super.annotation = newAnnotation; | ||
500 | + [self recalculateGeometryAnimated:NO]; | ||
501 | +} | ||
502 | + | ||
484 | @end | 503 | @end |
-
Please register or login to post a comment