Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Update annotation views before informing delegate #5287

Merged
merged 1 commit into from
Jun 8, 2016

Conversation

1ec5
Copy link
Contributor

@1ec5 1ec5 commented Jun 8, 2016

On each frame update, update annotation views before informing the delegate of the new frame. This allows the delegate to manipulate annotation views without fear of the SDK overriding those modifications.

For example, if you want a particular view-backed annotation other than the selected annotation to appear in front of any other view-backed annotations, your MGLMapViewDelegate can hold a strong reference to the view it provides for that annotation and implement this method:

- (void)mapViewDidFinishRenderingFrame:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered {
    // Make way for Its Preeminence!
    [self.preeminentAnnotationView.superview bringSubviewToFront:self.preeminentAnnotationView];
}

/ref #991 #5264
/cc @frederoni @boundsj @zugaldia

On each frame update, update annotation views before informing the delegate of the new frame. This allows the delegate to manipulate annotation views without fear of the SDK overriding those modifications.
@1ec5 1ec5 added bug iOS Mapbox Maps SDK for iOS annotations Annotations on iOS and macOS or markers on Android labels Jun 8, 2016
@1ec5 1ec5 added this to the ios-v3.3.0 milestone Jun 8, 2016
@1ec5 1ec5 self-assigned this Jun 8, 2016
@zugaldia
Copy link
Member

zugaldia commented Jun 8, 2016

/cc: @ivovandongen

@1ec5
Copy link
Contributor Author

1ec5 commented Jun 8, 2016

If the developer needs the previous behavior, in which the delegate gets notified before MGLMapView arranges its MGLAnnotationViews, MGLMapViewDelegate can implement -mapViewWillStartRenderingFrame: instead of -mapViewDidFinishRenderingFrame:fullyRendered:.

@boundsj
Copy link
Contributor

boundsj commented Jun 8, 2016

👍

@1ec5 1ec5 merged commit 4e80899 into release-ios-v3.3.0 Jun 8, 2016
@1ec5 1ec5 deleted the 1ec5-annotation-view-post-delegate-991 branch June 8, 2016 21:25
@andrewstay
Copy link

andrewstay commented Dec 22, 2016

@1ec5 Please note that this approach is extremely risky as the MGLAnnotationView gets reused for different annotations to be rendered. Therefore clients cannot hold a strong reference to it.

Moreover, in the SDK you already move to the front the selected annotation if it sits behind the other ones. Please consider exposing this to the map view interface.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 22, 2016

Therefore clients cannot hold a strong reference to it.

This change is unrelated to how MGLAnnotationView gets used or reused. Instead of holding a strong reference to the view in application code, consider calling -[MGLMapView viewForAnnotation:] to get a fresh reference to the view anytime you need it.

Moreover, in the SDK you already move to the front the selected annotation if it sits behind the other ones. Please consider exposing this to the map view interface.

Are you referring to the functionality added in #5264? Please feel free to open a new issue requesting a public API for controlling it; I’m not quite sure what kind of configurability you’re looking for.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants