summaryrefslogtreecommitdiff
path: root/platform/ios/src
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@users.noreply.github.com>2016-10-04 18:42:12 -0700
committerGitHub <noreply@github.com>2016-10-04 18:42:12 -0700
commit105673efc1c59e19f5352fb770405aa591cdebeb (patch)
tree7b57c89ad346a4e62c60c404338d0b34853ad02b /platform/ios/src
parent07315711d6b191a5812065bb76ab5beb33d995d9 (diff)
downloadqtlocation-mapboxgl-105673efc1c59e19f5352fb770405aa591cdebeb.tar.gz
[ios, macos] fixes #6160: allow updating multipoint coordinates (#6565)
Diffstat (limited to 'platform/ios/src')
-rw-r--r--platform/ios/src/MGLMapView.mm29
1 files changed, 29 insertions, 0 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index bc11303ee8..9067efc033 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1795,6 +1795,29 @@ public:
}
}
}
+ else if ([keyPath isEqualToString:@"coordinates"] && [object isKindOfClass:[MGLMultiPoint class]])
+ {
+ MGLMultiPoint *annotation = object;
+ MGLAnnotationTag annotationTag = (MGLAnnotationTag)(NSUInteger)context;
+ // We can get here because a subclass registered itself as an observer
+ // of the coordinates key path of a multipoint annotation but failed
+ // to handle the change. This check deters us from treating the
+ // subclass’s context as an annotation tag. If the context happens to
+ // match a valid annotation tag, the annotation will be unnecessarily
+ // but safely updated.
+ if (annotation == [self annotationWithTag:annotationTag])
+ {
+ // Update the annotation’s backing geometry to match the annotation model object.
+ _mbglMap->updateAnnotation(annotationTag, [annotation annotationObjectWithDelegate:self]);
+
+ // We don't current support shape multipoint annotation selection, but let's make sure
+ // deselection is handled just to avoid problems in the future.
+ if (annotationTag == _selectedAnnotationTag)
+ {
+ [self deselectAnnotation:annotation animated:YES];
+ }
+ }
+ }
}
+ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingZoomEnabled
@@ -2840,6 +2863,8 @@ public:
MGLAnnotationContext context;
context.annotation = annotation;
_annotationContextsByAnnotationTag[annotationTag] = context;
+
+ [(NSObject *)annotation addObserver:self forKeyPath:@"coordinates" options:0 context:(void *)(NSUInteger)annotationTag];
}
else if ( ! [annotation isKindOfClass:[MGLMultiPolyline class]]
|| ![annotation isKindOfClass:[MGLMultiPolygon class]]
@@ -3132,6 +3157,10 @@ public:
{
[(NSObject *)annotation removeObserver:self forKeyPath:@"coordinate" context:(void *)(NSUInteger)annotationTag];
}
+ else if ([annotation isKindOfClass:[MGLMultiPoint class]])
+ {
+ [(NSObject *)annotation removeObserver:self forKeyPath:@"coordinates" context:(void *)(NSUInteger)annotationTag];
+ }
_mbglMap->removeAnnotation(annotationTag);
}