Repository navigation
-[MGLMapView selectAnnotation:animated:] pans map to fit callout view - #11442
Conversation
|
This is a WIP PR (branched off https://github.com/mapbox/mapbox-gl-native/tree/jrex-9790-offscreen-annotation) - looking for feedback, and discussion about the animated parameters. Equivalent macOS changes are yet to be done. Some points for discussion:
/cc @lilykaiser |
|
Closed related PR #11257 (this PR is a superset) |
26f7bc4 to
8b6ffed
Compare
| } | ||
|
|
||
| - (id<MGLAnnotation>)randomOffscreenAnnotation { | ||
| NSArray *annotations = self.mapView.annotations; |
There was a problem hiding this comment.
This method also needs to remove unselectable offscreen annotations (i.e., shapes) from consideration, otherwise it can fail silently.
There was a problem hiding this comment.
Agreed - and I'll update the method to indicate that it just selects, er, selectable annotations.
|
|
||
| These are used to determine positioning. Currently only the top and bottom properties of the return | ||
| value are used. For example, `{ .top = -50.0, .left = 0.0, .bottom = 0.0, .right = 0.0 }` indicates | ||
| a 50 point margin above the presentation origin rect, in which the callout is assumed to be displayed. |
There was a problem hiding this comment.
Let’s also indicate what the default insets are.
|
|
||
| @param rect rect that the callout is presented from. This should be the same as the one passed in | ||
| `-presentCalloutFromRect:inView:constrainedToRect:animated:` | ||
| @return margins. Since this is a UIEdgeInsets, values should be negative. |
| method has no effect. | ||
|
|
||
| @param annotation The annotation object to select. | ||
| @param animated If `YES`, the callout view is animated into position. |
There was a problem hiding this comment.
This needs to be updated to say that the viewport moves to show the annotation.
There was a problem hiding this comment.
This also seems like a good place to talk about the animated parameter generally.
As implemented, the animated param controls whether or not the viewport is moved to show the annotation, not whether or not the viewport is moved with an animation. This seems potentially confusing.
I think the animated param should control how the viewport moves to show the annotation, not whether or not the viewport moves at all. For most cases, this would be what the developer expects: selecting an annotation indicates that it should probably be visible.
I’m less certain about how to or if we should handle the case where a newly selected annotation shouldn’t move the viewport.
There was a problem hiding this comment.
Yes, this is confusing 😢 As currently written it should match Mapkit, which is also confusing. I don't like the use if the word animated in this context.
I'm tempted to leave the functionality as is, but really try to make it clear through documentation.
Perhaps changing animated to something more appropriate in the new (not yet public) method, would help here, and pave the way for clarifying (or removing) the existing method.
8b6ffed to
c6b1052
Compare
There was a problem hiding this comment.
This note here is good. Let’s also make explicit whether or not setting selectedAnnotations will move the viewport (and point them in the direction of selectAnnotation:animated: if they need more control over that).
There was a problem hiding this comment.
Being that the macOS SDK isn’t productized and most readers of this changelog may not know about it, let’s omit that bit.
There was a problem hiding this comment.
The last sentence?
c6b1052 to
4787d7e
Compare
fabian-guerra
left a comment
There was a problem hiding this comment.
Hi, @julianrex.
I reviewed:
- Class/methods documentation is clear.
- Method names without prepositions and clear purpose.
- Code readability.
- Test cases test each scenario.
- There is no code side effects.
Besides the nits and adding the blurb to macOS changelog this PR LGTM.
There was a problem hiding this comment.
Nit: The return statement should be at the end of this line or between curly brackets.
if (annotations.count == 0) return nil;
There was a problem hiding this comment.
Nit: The return statement should be at the end of this line or between curly brackets.
…annotation just on screen.
a1aad9c to
ef0a67c
Compare

See #3249.
If
-[MGLMapView selectAnnotation:animated:]is called withanimated: YES, an offscreen annotation (and its callout) are moved to be just on screen. On-screen annotations are not moved.If
animatedisNOthen the annotation is not moved on screen.This requires #9790 (selecting offscreen annotations)