-
-
Notifications
You must be signed in to change notification settings - Fork 717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
userlocationfocus and userlocationlostfocus events added to geolocate_control #3847
Conversation
New Events: 1. trackuserlocationfocus 2. trackuserlocationlostfocus
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3847 +/- ##
==========================================
+ Coverage 86.55% 86.70% +0.15%
==========================================
Files 242 242
Lines 33042 33044 +2
Branches 2027 2009 -18
==========================================
+ Hits 28600 28652 +52
+ Misses 3469 3423 -46
+ Partials 973 969 -4 ☔ View full report in Codecov by Sentry. |
Geolocate control is missing a lot of coverage in terms of tests and state management. |
I will try to write the related tests. |
This is a breaking change in terms of API, isn't it? |
Do you want the old events to remain in their previous places and should I add new events beside them? |
Yes, I don't think there's another way to keep the old API and new at the same time, isn't it? |
… break the previous API.
I made the code changes. How should I mark old events and functions as deprecated? |
The best thing I can think of is this one: |
Please let me know if there are any changes needed. |
I'm not sure the added comments will be visible to users reading the geolocation API documentation here: Can you try and make sure the deprecation gets to this page somehow? |
I included a state diagram in my original implementation PR at mapbox/mapbox-gl-js#3781 which was eventually reworked into mapbox/mapbox-gl-js#4479. I recently had to implement the Geolocate Control button external to the map with it's own design and ended up needing to access the private |
@andrewharvey thanks, this is a great diagram!! I'll need to find a good way to incorporate this in the docs somehow so people can find this better, maybe using an image link to github user content or something, IDK... In any case, this PR is missing the docs update and conflict resolution to be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking deeply into this code, I don't understand why the old events are considered deprecated when there's no alternative to the two places that are being fired now.
This PR still needs work and proper design, preferably a diagram with which events are fired when "before" and "after" this change.
State Transitions and Events Description Based On Diagram. OFF -> ACTIVE WAITING ACTIVE WAITING -> OFF Explanation: Proposed Changes: BACKGROUND -> ACTIVE LOCK My Change: userLocationFocus (in addition to the existing event trackUserLocationStart) ACTIVE LOCK -> BACKGROUND My Change: userLocationLostFocus (in addition to the existing event trackUserLocationEnd) Rationale: Therefore, the old events trackUserLocationEnd and trackUserLocationStart are not deprecated. They are replaced in the two places mentioned above (Proposed Changes). |
So the events are not deprecated, but rather there are places where in the future, these event will not be fired. That will remind us to remove the code that fire the events when they are not needed, when releasing version 5. Please also fix the docs I changed as there's no real deprecation at this point. |
I've done the relevant change. |
I was struggling with documentation changes due to personal issues, so I didn't have time to work on it. Thank you for completing this PR. |
Location tracking can mean different things, in this context it was likely talking about the map camera updating as the GPS location updates, not the "blue dot" tracking the live GPS location updates. |
I've added the diagram to the docs, hoping future reader will find it useful: Thanks @andrewharvey! |
Launch Checklist
Resolves #3846
Geolocate Control's OFF and BACKGROUND states both triggering the same trackuserlocationend event, and the WAITING_ACTIVE and ACTIVE_LOCK states both triggering the trackuserlocationstart event, two new events were introduced to separate theme:
This differentiation allows for a more precise control mechanism, enabling developers to accurately respond to specific geolocator state changes and implement more sophisticated and responsive geolocation functionalities.