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

Refactored MGLUserLocationAnnotationView (redux) #5882

Merged
merged 23 commits into from
Aug 16, 2016

Conversation

friedbunny
Copy link
Contributor

This is a replacement PR for #5573 that targets master.

Additionally, I’ve rewritten #5816 so that the hit testing layer can be set by any subclass of MGLUserLocationAnnotationView.

/cc @frederoni @1ec5 @incanus @boundsj


CGPoint tapPointForUserLocation = self.userLocationAnnotationView.hitTestLayer.superlayer ? [singleTap locationInView:self.userLocationAnnotationView] : tapPoint;

CALayer *hitLayer = self.userLocationVisible ? [self.userLocationAnnotationView.hitTestLayer hitTest:tapPointForUserLocation] : nil;
Copy link
Contributor Author

@friedbunny friedbunny Aug 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn’t need to check again for self.userLocationVisible — will remove.

@friedbunny
Copy link
Contributor Author

Saw some weird behavior just now that I don’t have time to investigate, but the user dot wasn’t being updated/deselected when another annotation became selected. E.g., tapping another annotation while in course tracking mode would leave the puck on screen until the tracking mode was manually changed again.

Will investigate next week.

@friedbunny friedbunny force-pushed the 5039-MGLUserLocationAnnotationView-refactor branch from cd60f2a to 9ba5c91 Compare August 9, 2016 22:07
@friedbunny
Copy link
Contributor Author

Rebased again after v3.3.4 was merged back to master, which included a backport of 7aec17d in #5894.

@friedbunny friedbunny self-assigned this Aug 12, 2016
@friedbunny friedbunny force-pushed the 5039-MGLUserLocationAnnotationView-refactor branch from 9ba5c91 to 71d9687 Compare August 12, 2016 20:54
@friedbunny
Copy link
Contributor Author

friedbunny commented Aug 13, 2016

380d54a9d5106fb957455c4376e086634ff05f39 fixes the issue where the annotation was not updating immediately.

The didUpdateUserLocation: method has been changed to update, which is again called from -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:].

A separate method that’s called when the user’s location changes shouldn’t be necessary, as the existing userLocation property will already contain this information.

The user location annotation needs updates more frequently than once per location event — it needs to respond to user interaction, viewport changes, and user tracking mode changes.

Very open to naming suggestions for update.

@friedbunny
Copy link
Contributor Author

Updated the docs a bit. Is the @warning too much?

screen shot 2016-08-12 at 10 41 26 pm

user interaction, a change in the user’s location, when the user tracking mode
changes, or when the viewport changes.

@warning During user interaction with the map, this method may be called many
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No keyword is needed here, although @note is fine if you think it’s sufficiently important. @warning should be reserved for pitfalls that may lead to data loss or similarly catastrophic outcomes.

@incanus
Copy link
Contributor

incanus commented Aug 15, 2016

The didUpdateUserLocation: method has been changed to update, which is again called from -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:].

Can you say more about this @friedbunny? didUpdateUserLocation: is akin to how MapKit does things.

@friedbunny friedbunny force-pushed the 5039-MGLUserLocationAnnotationView-refactor branch from 1806121 to 824c09f Compare August 15, 2016 18:19
@friedbunny
Copy link
Contributor Author

Can you say more about this @friedbunny? didUpdateUserLocation: is akin to how MapKit does things.

@frederoni added -[MGLUserLocationAnnotationView didUpdateUserLocation:], which became the sole way the user location annotation was updated with the removal of [annotationView setupLayers] from -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:] in 91ec7cb#diff-20502b6bc02986a4398d0da84b2d4b94L4683.

I renamed -[MGLUserLocationAnnotationView didUpdateUserLocation:] to -[MGLUserLocationAnnotationView update] and removed its MGLUserLocation value, because this is already always available via MGLUserLocationAnnotationView.userLocation.

I then re-added the call to -[MGLUserLocationAnnotationView update] (changed from a direct call to -setupLayers previously) in -[MGLMapView updateUserLocationAnnotationViewAnimatedWithDuration:], so that the user location annotation can update when the user interacts with the map, when the tracking mode changes, etc.

-[MGLMapViewDelegate mapView:didUpdateUserLocation:] is unchanged.

@incanus
Copy link
Contributor

incanus commented Aug 15, 2016 via email

@friedbunny
Copy link
Contributor Author

friedbunny commented Aug 15, 2016

This is ready for review 👓 again — thanks y’all.

I should note: this is a fairly pure refactor. The main part that has changed versus v3.3.x is that MGLUserLocationAnnotationView is now available. The functionality of the existing dot/puck now lives in MGLFaux3DUserLocationAnnotationView and is unchanged.

@1ec5 1ec5 added the beta blocker Blocks the next beta release label Aug 15, 2016
@friedbunny friedbunny force-pushed the 5039-MGLUserLocationAnnotationView-refactor branch from 824c09f to 634f680 Compare August 16, 2016 14:42
@friedbunny
Copy link
Contributor Author

Rebased again — I’m going to aim for merging this afternoon.

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 iOS Mapbox Maps SDK for iOS refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants