Authored by Justin R. Miller

fixes #92: properly order user location annotations & disallow gestures

... ... @@ -22,4 +22,6 @@
- (void)moveLayersBy:(CGPoint)delta;
- (CALayer *)overlayHitTest:(CGPoint)point;
@end
... ...
... ... @@ -10,8 +10,14 @@
#import "RMMarker.h"
#import "RMAnnotation.h"
#import "RMPixel.h"
#import "RMMapView.h"
@implementation RMMapOverlayView
{
RMAnnotation *_userLocationAnnotation;
RMAnnotation *_accuracyCircleAnnotation;
RMAnnotation *_trackingHaloAnnotation;
}
+ (Class)layerClass
{
... ... @@ -58,4 +64,30 @@
[self.layer scrollPoint:CGPointMake(-delta.x, -delta.y)];
}
- (CALayer *)overlayHitTest:(CGPoint)point
{
RMMapView *mapView = ((RMMapView *)self.superview);
if ( ! _userLocationAnnotation)
_userLocationAnnotation = (RMAnnotation *)mapView.userLocation;
if ( ! _accuracyCircleAnnotation)
for (RMAnnotation *annotation in mapView.annotations)
if ([annotation.annotationType isEqualToString:kRMAccuracyCircleAnnotationTypeName])
_accuracyCircleAnnotation = annotation;
if ( ! _trackingHaloAnnotation)
for (RMAnnotation *annotation in mapView.annotations)
if ([annotation.annotationType isEqualToString:kRMTrackingHaloAnnotationTypeName])
_trackingHaloAnnotation = annotation;
_userLocationAnnotation.layer.hidden = _accuracyCircleAnnotation.layer.hidden = _trackingHaloAnnotation.layer.hidden = YES;
CALayer *hit = [self.layer hitTest:point];
_userLocationAnnotation.layer.hidden = _accuracyCircleAnnotation.layer.hidden = _trackingHaloAnnotation.layer.hidden = NO;
return hit;
}
@end
... ...
... ... @@ -1343,7 +1343,7 @@
- (void)handleSingleTap:(UIGestureRecognizer *)recognizer
{
CALayer *hit = [_overlayView.layer hitTest:[recognizer locationInView:self]];
CALayer *hit = [_overlayView overlayHitTest:[recognizer locationInView:self]];
if ( ! hit)
{
... ... @@ -1393,7 +1393,7 @@
- (void)handleDoubleTap:(UIGestureRecognizer *)recognizer
{
CALayer *hit = [_overlayView.layer hitTest:[recognizer locationInView:self]];
CALayer *hit = [_overlayView overlayHitTest:[recognizer locationInView:self]];
if ( ! hit)
{
... ... @@ -1450,7 +1450,7 @@
if ([recognizer isKindOfClass:[UIPanGestureRecognizer class]])
{
// check whether our custom pan gesture recognizer should start recognizing the gesture
CALayer *hit = [_overlayView.layer hitTest:[recognizer locationInView:_overlayView]];
CALayer *hit = [_overlayView overlayHitTest:[recognizer locationInView:_overlayView]];
if ([hit isEqual:_overlayView.layer])
return NO;
... ... @@ -2789,6 +2789,7 @@
accuracyCircleAnnotation.annotationType = kRMAccuracyCircleAnnotationTypeName;
accuracyCircleAnnotation.clusteringEnabled = NO;
accuracyCircleAnnotation.layer = [[RMCircle alloc] initWithView:self radiusInMeters:newLocation.horizontalAccuracy];
accuracyCircleAnnotation.layer.zPosition = -MAXFLOAT;
accuracyCircleAnnotation.isUserLocationAnnotation = YES;
((RMCircle *)accuracyCircleAnnotation.layer).lineColor = [UIColor colorWithRed:0.378 green:0.552 blue:0.827 alpha:0.7];
... ... @@ -2822,6 +2823,7 @@
// create image marker
//
trackingHaloAnnotation.layer = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"TrackingDotHalo.png"]];
trackingHaloAnnotation.layer.zPosition = -MAXFLOAT + 1;
trackingHaloAnnotation.isUserLocationAnnotation = YES;
[CATransaction begin];
... ...
... ... @@ -25,6 +25,8 @@
layer = [[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"TrackingDot.png"]];
layer.zPosition = -MAXFLOAT + 2;
annotationType = [kRMUserLocationAnnotationTypeName retain];
clusteringEnabled = NO;
... ...