mapbox / DEPRECATED-mapbox-ios-sdk

REPLACED – use https://www.mapbox.com/ios-sdk instead
https://github.com/mapbox/mapbox-gl-native
Other
322 stars 8 forks source link

Detect taps on annotation's sublayers. #603

Closed mikrobi closed 8 years ago

mikrobi commented 9 years ago

In our project we have more complex, custom annotation with sub layers. Tapping on these sub layers should just be treated the same way like tapping the annotation's layer. Instead of hacking a quick fix, I've build a more general solution that should behave similar to the original implementation.

fixes #190

rodericj commented 9 years ago

@mikrobi, I'm looking to use this implementation as I believe I have a similar setup. I've got a custom annotation which is 2 different UIImageView's layers. I'm wondering if your implementation is meant to solve the problem that I'm having which is that I'd like to tap on any of the images and have the annotation callout displayed. Is that your intention with this fix?

My annotation does not have 1 or 2 sublayers, so your implementation doesn't actually call [self tapOnAnnotation:tappedAnnotation atPoint:[recognizer locationInView:self]]; With a slight modification of your code I'm able to detect the tap on one of my sublayers which then initiates the tap on annotation method.

Anyway, it seems that your implementation works only in the specific case where there are 1 or 2 sublayers, not the full general case.

Thoughts?

rodericj commented 9 years ago

The issue that I was having was that I did not implement

- (void)tapOnAnnotation:(RMAnnotation *)annotation onMap:(RMMapView *)map {
    [map selectAnnotation:annotation animated:YES];
}

But still looking at the code, I'm wondering why the method -(void)tapOnLabelForAnnotation:atPoint is the appropriate method that is called. This is more of a framework question, but I'm not really tapping on a label, but the annotation itself. Is this some sort of legacy naming structure?