Question

I've got a problem with the route-me framework and marker labels. I'm trying now about 5 hours with no luck and searched almost every forum topic on the web about this. I want to add a marker label with a UIButtonTypeDetailDisclosure-Button on it. When I add the Button to the UIView that should be the label I can't click on the Button.

My code is as follows:

- (void)tapOnMarker:(RMMarker*)marker onMap:(RMMapView*)map {
    UIView *frame = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    button.frame = CGRectMake(0, 0, 34, 34);
    button.enabled = YES;
    button.userInteractionEnabled = YES;
    [button addTarget:self action:@selector(markerLabelButtonPressed:) forControlEvents:UIControlEventTouchUpInside];

    [frame addSubview:button];
    [marker setLabel:frame];
    [marker showLabel];
}

-(void)markerLabelButtonPressed:(id)sender {
    NSLog(@"pressed");
}

I hope anyone may help me with this. Thanks :)

I you need any more information please let me know!

Was it helpful?

Solution

Ok finally i managed to solve the problem. Maybe it's a little dirty workaround, but anyway it's working ;)

I modified the route-me framework and added a method called

- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map onLayer:(CALayer *)layer;

In RMMapView.m I added the following Lines in Line 584:

 else if ([superlayer superlayer] != nil && [[[superlayer superlayer] superlayer] isKindOfClass: [RMMarker class]]) {
     if (_delegateHasTapOnLabelForMarker) {
         [delegate tapOnLabelForMarker:(RMMarker*)[[superlayer superlayer] superlayer] onMap:self onLayer:superlayer];
     }
 } 

Now then the disclosurebutton is tapped this part of the code is executed and my method is called. When any other area of the marker label is tapped the

- (void) tapOnLabelForMarker: (RMMarker*) marker onMap: (RMMapView*) map;

method is called.

Hope this helps anyone else ;)

OTHER TIPS

This issue is resolved by this pull request https://github.com/route-me/route-me/pull/161.

It has been merged in route-me code on feb 21st 2012.

Take a look to this thread in the route google groups list: http://groups.google.com/group/route-me-map/browse_thread/thread/343cb3ebfd9480e3

someone was answered with some code for marker "balloon" labels that uses a close button.

I had trouble with this solution, and I don't want to be one of those people who tell you to do it differently because you may have good cause to do things the way you are doing them.

I took this initial approach, then via another thread I realized: If I only want to have one callout at a time, I can just manage him as a subview of the mapView and use the helper methods of the mapView.markerManager. A RMMarker object has a data pointer which you can use to fill in the contents of your callout bubble.

This saved me a lot of time and I have a satisfactory solution that doesn't get that dirty at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top