diff options
-rw-r--r-- | platform/ios/src/MGLAnnotationView.mm | 5 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm index 0e904779d5..5e0ae3b848 100644 --- a/platform/ios/src/MGLAnnotationView.mm +++ b/platform/ios/src/MGLAnnotationView.mm @@ -239,7 +239,10 @@ } else if (dragState == MGLAnnotationViewDragStateCanceling) { - NSAssert(self.annotation, @"Annotation property should not be nil."); + if (!self.annotation) { + [NSException raise:NSInvalidArgumentException + format:@"Annotation property should not be nil."]; + } self.panGestureRecognizer.enabled = NO; self.longPressRecognizer.enabled = NO; self.center = [self.mapView convertCoordinate:self.annotation.coordinate toPointToView:self.mapView]; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index f0aa2804a6..8872261a88 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1519,14 +1519,18 @@ public: return nil; } } - + // Handle the case of an offset annotation view by converting the tap point to be the geo location // of the annotation itself that the view represents for (MGLAnnotationView *view in self.annotationContainerView.annotationViews) { if (view.centerOffset.dx != 0 || view.centerOffset.dy != 0) { if (CGRectContainsPoint(view.frame, tapPoint)) { - NSAssert(view.annotation, @"Annotation's view annotation property should not be nil."); + if (!view.annotation) { + [NSException raise:NSInvalidArgumentException + format:@"Annotation view's annotation property should not be nil."]; + } + CGPoint annotationPoint = [self convertCoordinate:view.annotation.coordinate toPointToView:self]; tapPoint = annotationPoint; } |