summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2016-09-27 13:49:54 -0700
committerJesse Bounds <jesse@rebounds.net>2016-09-27 15:24:19 -0700
commitc6abc0ea89f2e44258f43aa4c3c6e00b1b8b04f7 (patch)
tree417ba621265b94a75ad2c89be4dde7670af3c420
parenta6aa786f35824922aee0d2baad94e4ce9f71e79c (diff)
downloadqtlocation-mapboxgl-c6abc0ea89f2e44258f43aa4c3c6e00b1b8b04f7.tar.gz
[ios] Always show annotation view even when view reuse is not used
This fixes an issue where the map view would drop annotation views if the developer did not make full use of the reuse queue. The fixes are: - Guard against enqueuing a view for reuse if it does not have a `viewReuseIdentifier`. Previously, if the app developer created a new annotation view with no reuse id each time `[MGLMapViewDelegate mapView:viewForAnnotation:]` was called and then the view was scrolled offscreen, we attempted to add the view to the reuse queue (for no good reason) and did not update the views center ever again. This change avoids the reuse queue and just updates the center always. - Add any annotation view that should be displayed but is not in the annotation container view to the annotation container view. Previously, if the app developer created a new annotation view with a reuse id each time `[MGLMapViewDelegate mapView:viewForAnnotation:]` was called, and then if the annotation was scrolled off and then on screen again, we did not add the new view to the container view because it was not happening in the normal `addAnnotation` cycle. This adds add logic to catch that case and add annotation views created in this way to the view.
-rw-r--r--platform/ios/src/MGLMapView.mm6
1 files changed, 5 insertions, 1 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 273f2715fa..f2a365f455 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -4572,6 +4572,10 @@ public:
annotationView.mapView = self;
annotationView.center = [self convertCoordinate:annotationContext.annotation.coordinate toPointToView:self];
annotationContext.annotationView = annotationView;
+
+ if (!annotationView.superview) {
+ [self.annotationContainerView insertSubview:annotationView atIndex:0];
+ }
}
else
{
@@ -4581,7 +4585,7 @@ public:
}
bool annotationViewIsVisible = CGRectContainsRect(viewPort, annotationView.frame);
- if (!annotationViewIsVisible)
+ if (!annotationViewIsVisible && annotationContext.viewReuseIdentifier)
{
[self enqueueAnnotationViewForAnnotationContext:annotationContext];
}