Permalink
Browse files

Adds tapOnLabelForMarker:onMap:onLayer: method to RMMapViewDelegate p…

…rotocol.

This method allows the implementation of tappable buttons in markers label.

For instance, you can add a button layer with name @"NameOfYourButtonLayerHere" to a marker label and implement the method tapOnLabelForMarker:onMap:onLayer: for your RMMapViewDelegate as follows:

- (void) tapOnLabelForMarker:(RMMarker*)marker
                       onMap:(RMMapView*)map
                       onLayer:(CALayer *)layer
{
    if (layer.name == @"NameOfYourButtonLayerHere") {
		//Code to serve button tap here
    }
}

See also http://stackoverflow.com/questions/5967909/route-me-marker-label-with-uibuttontypedetaildisclosure-button-button-isnt-cl
  • Loading branch information...
1 parent b68dfd2 commit 8dc751724a2b231c2b26dde93c94bd607509da27 @dguerri dguerri committed Jan 27, 2012
Showing with 9 additions and 0 deletions.
  1. +1 −0 MapView/Map/RMMapView.h
  2. +7 −0 MapView/Map/RMMapView.m
  3. +1 −0 MapView/Map/RMMapViewDelegate.h
View
@@ -139,6 +139,7 @@ typedef struct {
BOOL _delegateHasSingleTapOnMap;
BOOL _delegateHasTapOnMarker;
BOOL _delegateHasTapOnLabelForMarker;
+ BOOL _delegateHasTapOnLabelForMarkerOnLayer;
BOOL _delegateHasAfterMapTouch;
BOOL _delegateHasShouldDragMarker;
BOOL _delegateHasDidDragMarker;
View
@@ -193,6 +193,7 @@ - (void) setDelegate: (id<RMMapViewDelegate>) _delegate
_delegateHasTapOnMarker = [(NSObject*) delegate respondsToSelector:@selector(tapOnMarker:onMap:)];
_delegateHasTapOnLabelForMarker = [(NSObject*) delegate respondsToSelector:@selector(tapOnLabelForMarker:onMap:)];
+ _delegateHasTapOnLabelForMarkerOnLayer = [(NSObject*) delegate respondsToSelector:@selector(tapOnLabelForMarker:onMap:onLayer:)];
_delegateHasAfterMapTouch = [(NSObject*) delegate respondsToSelector: @selector(afterMapTouch:)];
@@ -586,10 +587,16 @@ - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
if (_delegateHasTapOnLabelForMarker) {
[delegate tapOnLabelForMarker:(RMMarker*)superlayer onMap:self];
}
+ if (_delegateHasTapOnLabelForMarkerOnLayer) {
+ [delegate tapOnLabelForMarker:(RMMarker*)superlayer onMap:self onLayer:hit];
+ }
} else if ([superlayer superlayer] != nil && [[superlayer superlayer] isKindOfClass: [RMMarker class]]) {
if (_delegateHasTapOnLabelForMarker) {
[delegate tapOnLabelForMarker:(RMMarker*)[superlayer superlayer] onMap:self];
}
+ if (_delegateHasTapOnLabelForMarkerOnLayer) {
+ [delegate tapOnLabelForMarker:(RMMarker*)[superlayer superlayer] onMap:self onLayer:hit];
+ }
} else if (_delegateHasSingleTapOnMap) {
[delegate singleTapOnMap: self At: [touch locationInView:self]];
}
@@ -57,6 +57,7 @@
- (void) tapOnMarker: (RMMarker*) marker onMap: (RMMapView*) map;
- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map;
+- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map onLayer:(CALayer *)layer;
- (BOOL) mapView:(RMMapView *)map shouldDragMarker:(RMMarker *)marker withEvent:(UIEvent *)event;
- (void) mapView:(RMMapView *)map didDragMarker:(RMMarker *)marker withEvent:(UIEvent *)event;

0 comments on commit 8dc7517

Please sign in to comment.