You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Implement Responsive User Location Tracking Mode #2049
The User Location tracking mode (None, Follow, Bearing) was disabled in #1856 as the User Location dot was being updated on the main UI thread. The core logic is there, but it needs to be implemented in a more efficient way so that the UI remains responsive.
@ljbade, on iOS, MGLMapView doesn’t do anything special. But it seems that Core Location is doing a better job of coalescing location updates than what we’re using on Android: #1676.
But it seems that Core Location is doing a better job of coalescing location updates than what we’re using on Android
Exactly. We need to put a regulator / distance filter on updates to location or specifically that a certain amount of distance / time needs to elapse before updating the dot on the map.
Currently when I try to set up tracking in the onCreate it draws the blue marker in the top left corner, digging through the code on git I found that this was because the position of the marker is being set relative to the mapview by dividing width and height by 2 (height and width would be 0 while onCreate is being called).
I altered my code to include a button I could press to start tracking in order to bypass the problem, however even though the screen is centred on the correct position, the blue dot does not draw to the screen.
In the UserLocationView class and in the update method, why are you setting the blue marker position by dividing the screen/height width by 2 to find the centre point of the screen. Why not use the latitude and longitude to draw the marker like you would with a regular addMarker call or a screen centre?
If the code even worked properly, wouldn't moving around the map with user input reposition the blue dot in the wrong place i.e. keep it in the centre of the screen no matter where the user navigates to on the map?
@Buckley404, reading through your comment I believe you are using the incorrect method. If you want the user location to show on the map in similar fashion as a marker you should call
One thing I need to add to this is that current compass implementation is not on par with the one from Google. Current implemented code using accelerometer and magnetometer is generally spoken the accepted way of implementing a compass (as seen in books, SO and tutorials). It seems Google is adding some extra elements to the equitation or using another configuration to calculate values. One of the most notable differences is that Google's implementation is not impacted when switching perspective or tilting the device.
Thanks again @tobrun, I'll recheck my code after work however I think I was using both methods. I must have just confused myself. FYI google might just be setting minimum thresholds for when the compass should be affected by gyro.
@Buckley404 I have been trying to mimic their behaviour for quite some time and I now believe that Google is doing something different than just using the sensors as we are doing.
FYI I added thresholds in latest code, we could further optimise this by implementing a low pas filter.
Activity
erf commentedon Aug 12, 2015
Could it be added as an annotation?
ljbade commentedon Aug 13, 2015
@bleege Is the issue that there is too many events?
erf commentedon Aug 13, 2015
i made a lowpass filter in #1968 which could be used
erf commentedon Aug 13, 2015
in addition to some minimal time / angle diff
erf commentedon Aug 13, 2015
I think you should move out the setDirection call from updateMap to the onCompassChange event.
bleege commentedon Aug 13, 2015
Yes.
ljbade commentedon Aug 13, 2015
@bleege How does iOS handle that?
1ec5 commentedon Aug 14, 2015
@ljbade, on iOS, MGLMapView doesn’t do anything special. But it seems that Core Location is doing a better job of coalescing location updates than what we’re using on Android: #1676.
bleege commentedon Aug 14, 2015
Exactly. We need to put a regulator / distance filter on updates to location or specifically that a certain amount of distance / time needs to elapse before updating the dot on the map.
ljbade commentedon Aug 15, 2015
@bleege I recall the LOST framework has this ability to filter (certainly Google Play services do).
We still need to work in @erf's compass filter for that data.
ljbade commentedon Aug 15, 2015
I was getting confused between location/GPS events and map position change events.
97 remaining items
tobrun commentedon Dec 8, 2015
I'm working on this again, because I have noticed 2 bugs on current progress that need to fixed asap
tobrun commentedon Dec 17, 2015
To clarify above:
tobrun commentedon Dec 23, 2015
The new camera API from @bleege will help resolve remaining issue on this ticket:
#3396 contains the fix for animated location updates with user tracking mode enabled.
Todo list to close this issue:
setBearingas done forsetCenterCoordinateBackport setBearing with new Camera api #3397UserLocationViewRemove Jitter from UserLocationView #3398Buckley404 commentedon Jan 2, 2016
Is this working correctly now?
Currently when I try to set up tracking in the onCreate it draws the blue marker in the top left corner, digging through the code on git I found that this was because the position of the marker is being set relative to the mapview by dividing width and height by 2 (height and width would be 0 while onCreate is being called).
I altered my code to include a button I could press to start tracking in order to bypass the problem, however even though the screen is centred on the correct position, the blue dot does not draw to the screen.
In the UserLocationView class and in the update method, why are you setting the blue marker position by dividing the screen/height width by 2 to find the centre point of the screen. Why not use the latitude and longitude to draw the marker like you would with a regular addMarker call or a screen centre?
If the code even worked properly, wouldn't moving around the map with user input reposition the blue dot in the wrong place i.e. keep it in the centre of the screen no matter where the user navigates to on the map?
tobrun commentedon Jan 5, 2016
@Buckley404, reading through your comment I believe you are using the incorrect method. If you want the user location to show on the map in similar fashion as a marker you should call
instead of:
Let me know if you have any other questions.
tobrun commentedon Jan 5, 2016
#3397 landed with f80673b
tobrun commentedon Jan 5, 2016
One thing I need to add to this is that current
compassimplementation is not on par with the one from Google. Current implemented code usingaccelerometerandmagnetometeris generally spoken the accepted way of implementing a compass (as seen in books, SO and tutorials). It seems Google is adding some extra elements to the equitation or using another configuration to calculate values. One of the most notable differences is that Google's implementation is not impacted when switching perspective or tilting the device.Buckley404 commentedon Jan 5, 2016
Thanks again @tobrun, I'll recheck my code after work however I think I was using both methods. I must have just confused myself. FYI google might just be setting minimum thresholds for when the compass should be affected by gyro.
tobrun commentedon Jan 5, 2016
@Buckley404 I have been trying to mimic their behaviour for quite some time and I now believe that Google is doing something different than just using the sensors as we are doing.
FYI I added thresholds in latest code, we could further optimise this by implementing a low pas filter.