Authored by devel-hb

new delegate method: tap on marker

@@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
21 BOOL delegateHasBeforeMapZoomByFactor; 21 BOOL delegateHasBeforeMapZoomByFactor;
22 BOOL delegateHasAfterMapZoomByFactor; 22 BOOL delegateHasAfterMapZoomByFactor;
23 BOOL delegateHasDoubleTapOnMap; 23 BOOL delegateHasDoubleTapOnMap;
  24 + BOOL delegateHasTapOnMarker;
24 @end 25 @end
25 26
26 @implementation RMMapView 27 @implementation RMMapView
@@ -94,9 +95,7 @@ @@ -94,9 +95,7 @@
94 delegateHasAfterMapZoomByFactor = [(NSObject*) delegate respondsToSelector: @selector(afterMapZoom: byFactor: near:)]; 95 delegateHasAfterMapZoomByFactor = [(NSObject*) delegate respondsToSelector: @selector(afterMapZoom: byFactor: near:)];
95 96
96 delegateHasDoubleTapOnMap = [(NSObject*) delegate respondsToSelector: @selector(doubleTapOnMap:)]; 97 delegateHasDoubleTapOnMap = [(NSObject*) delegate respondsToSelector: @selector(doubleTapOnMap:)];
97 -  
98 - NSLog(@"%d %d %d %d %d", delegateHasBeforeMapMove, delegateHasAfterMapMove, delegateHasBeforeMapZoomByFactor, delegateHasAfterMapZoomByFactor, delegateHasDoubleTapOnMap);  
99 - 98 + delegateHasTapOnMarker = [(NSObject*) delegate respondsToSelector:@selector(tapOnMarker:onMap:)];
100 } 99 }
101 100
102 - (id<RMMapViewDelegate>) delegate 101 - (id<RMMapViewDelegate>) delegate
@@ -247,8 +246,7 @@ @@ -247,8 +246,7 @@
247 // When factoring, beware these two instructions need to happen in this order. 246 // When factoring, beware these two instructions need to happen in this order.
248 [RMMapContents setPerformExpensiveOperations:YES]; 247 [RMMapContents setPerformExpensiveOperations:YES];
249 } 248 }
250 - //*************************************************************************************  
251 - //Double-tap detection (currently used for debugging pixelToLatLng() method) 249 +
252 if (touch.tapCount == 2) 250 if (touch.tapCount == 2)
253 { 251 {
254 if (delegateHasDoubleTapOnMap) { 252 if (delegateHasDoubleTapOnMap) {
@@ -258,7 +256,14 @@ @@ -258,7 +256,14 @@
258 // [contents zoomInToNextNativeZoom]; 256 // [contents zoomInToNextNativeZoom];
259 } 257 }
260 } 258 }
261 - //*************************************************************************************** 259 +
  260 + if (touch.tapCount == 1)
  261 + {
  262 + CALayer* hit = [contents.overlay hitTest:[touch locationInView:self]];
  263 + if (hit != nil && [hit isMemberOfClass: [RMMarker class]]) {
  264 + if (delegateHasTapOnMarker) [delegate tapOnMarker: (RMMarker*) hit onMap: self];
  265 + }
  266 + }
262 267
263 // [contents recalculateImageSet]; 268 // [contents recalculateImageSet];
264 } 269 }
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 @class RMMapView; 11 @class RMMapView;
  12 +@class RMMarker;
12 13
13 @protocol RMMapViewDelegate 14 @protocol RMMapViewDelegate
14 15
@@ -22,4 +23,6 @@ @@ -22,4 +23,6 @@
22 23
23 - (void) doubleTapOnMap: (RMMapView*) map; 24 - (void) doubleTapOnMap: (RMMapView*) map;
24 25
  26 +- (void) tapOnMarker: (RMMarker*) marker onMap: (RMMapView*) map;
  27 +
25 @end 28 @end
@@ -16,7 +16,8 @@ extern NSString * const RMMarkerBlueKey; @@ -16,7 +16,8 @@ extern NSString * const RMMarkerBlueKey;
16 extern NSString * const RMMarkerRedKey; 16 extern NSString * const RMMarkerRedKey;
17 17
18 @interface RMMarker : RMMapLayer <RMMovingMapLayer> { 18 @interface RMMarker : RMMapLayer <RMMovingMapLayer> {
19 - RMXYPoint location; 19 + RMXYPoint location;
  20 + NSObject* data;
20 } 21 }
21 22
22 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName; 23 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName;
@@ -29,6 +30,7 @@ extern NSString * const RMMarkerRedKey; @@ -29,6 +30,7 @@ extern NSString * const RMMarkerRedKey;
29 - (id) initWithNamedStyle: (NSString*) styleName; 30 - (id) initWithNamedStyle: (NSString*) styleName;
30 31
31 @property (assign, nonatomic) RMXYPoint location; 32 @property (assign, nonatomic) RMXYPoint location;
  33 +@property (retain) NSObject* data;
32 34
33 // Call this with either RMMarkerBlue or RMMarkerRed for the key. 35 // Call this with either RMMarkerBlue or RMMarkerRed for the key.
34 + (CGImageRef) markerImage: (NSString *) key; 36 + (CGImageRef) markerImage: (NSString *) key;
@@ -21,6 +21,7 @@ static CGImageRef _markerBlue = nil; @@ -21,6 +21,7 @@ static CGImageRef _markerBlue = nil;
21 @implementation RMMarker 21 @implementation RMMarker
22 22
23 @synthesize location; 23 @synthesize location;
  24 +@synthesize data;
24 25
25 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName 26 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName
26 { 27 {