-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathTiMapMarkerAnnotationView.m
66 lines (59 loc) · 1.93 KB
/
TiMapMarkerAnnotationView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-Present by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#import "TiMapMarkerAnnotationView.h"
#import "TiMapAnnotationProxy.h"
#import "TiMapView.h"
@implementation TiMapMarkerAnnotationView
- (id)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier map:(TiMapView *)map_
{
if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
}
return self;
}
- (void)dealloc
{
RELEASE_TO_NIL(lastHitName);
[super dealloc];
}
- (NSString *)lastHitName
{
NSString *result = lastHitName;
[lastHitName autorelease];
lastHitName = nil;
return result;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
UIView *result = [super hitTest:point withEvent:event];
if (result == nil) {
for (UIView *ourSubView in [self subviews]) {
CGPoint subPoint = [self convertPoint:point toView:ourSubView];
for (UIView *ourSubSubView in [ourSubView subviews]) {
if (CGRectContainsPoint([ourSubSubView frame], subPoint) &&
[ourSubSubView isKindOfClass:[UILabel class]]) {
NSString *labelText = [(UILabel *)ourSubSubView text];
TiMapAnnotationProxy *ourProxy = (TiMapAnnotationProxy *)[self annotation];
RELEASE_TO_NIL(lastHitName);
if ([labelText isEqualToString:[ourProxy title]]) {
lastHitName = [@"title" retain];
} else if ([labelText isEqualToString:[ourProxy subtitle]]) {
lastHitName = [@"subtitle" retain];
}
return nil;
}
}
if (CGRectContainsPoint([ourSubView bounds], subPoint)) {
RELEASE_TO_NIL(lastHitName);
lastHitName = [@"annotation" retain];
return nil;
}
}
}
RELEASE_TO_NIL(lastHitName);
return result;
}
@end