summaryrefslogtreecommitdiff
path: root/platform/ios/src/MGLMapView.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/src/MGLMapView.mm')
-rw-r--r--platform/ios/src/MGLMapView.mm26
1 files changed, 10 insertions, 16 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 507a0846d9..1b07c68cf3 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1597,7 +1597,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
#pragma mark - Properties -
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(__unused void *)context
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"hidden"] && object == _attributionButton)
{
@@ -1608,19 +1608,16 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
[MGLMapboxEvents ensureMetricsOptoutExists];
}
}
- else if ([keyPath isEqualToString:@"coordinate"] && [object conformsToProtocol:@protocol(MGLAnnotation)])
+ else if ([keyPath isEqualToString:@"coordinate"] && [object conformsToProtocol:@protocol(MGLAnnotation)] && ![object isKindOfClass:[MGLMultiPoint class]])
{
id <MGLAnnotation> annotation = object;
- MGLAnnotationTag annotationTag = [self annotationTagForAnnotation:annotation];
- if (annotationTag != MGLAnnotationTagNotFound)
+ MGLAnnotationTag annotationTag = (MGLAnnotationTag)(NSUInteger)context;
+ const mbgl::LatLng latLng = MGLLatLngFromLocationCoordinate2D(annotation.coordinate);
+ MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag];
+ _mbglMap->updatePointAnnotation(annotationTag, { latLng, annotationImage.styleIconIdentifier.UTF8String ?: "" });
+ if (annotationTag == _selectedAnnotationTag)
{
- const mbgl::LatLng latLng = MGLLatLngFromLocationCoordinate2D(annotation.coordinate);
- MGLAnnotationImage *annotationImage = [self imageOfAnnotationWithTag:annotationTag];
- _mbglMap->updatePointAnnotation(annotationTag, { latLng, annotationImage.styleIconIdentifier.UTF8String ?: "" });
- if (annotationTag == _selectedAnnotationTag)
- {
- [self deselectAnnotation:annotation animated:YES];
- }
+ [self deselectAnnotation:annotation animated:YES];
}
}
}
@@ -2452,6 +2449,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
_annotationContextsByAnnotationTag[annotationTag] = context;
if ([annotation isKindOfClass:[NSObject class]]) {
+ NSAssert(![annotation isKindOfClass:[MGLMultiPoint class]], @"Point annotation should not be MGLMultiPoint.");
[(NSObject *)annotation addObserver:self forKeyPath:@"coordinate" options:0 context:(void *)(NSUInteger)annotationTag];
}
}
@@ -2469,10 +2467,6 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
MGLAnnotationContext context;
context.annotation = annotation;
_annotationContextsByAnnotationTag[annotationTag] = context;
-
- if ([annotation isKindOfClass:[NSObject class]]) {
- [(NSObject *)annotation addObserver:self forKeyPath:@"coordinate" options:0 context:(void *)(NSUInteger)annotationTag];
- }
}
}
@@ -2600,7 +2594,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
_annotationContextsByAnnotationTag.erase(annotationTag);
- if ([annotation isKindOfClass:[NSObject class]])
+ if ([annotation isKindOfClass:[NSObject class]] && ![annotation isKindOfClass:[MGLMultiPoint class]])
{
[(NSObject *)annotation removeObserver:self forKeyPath:@"coordinate" context:(void *)(NSUInteger)annotationTag];
}