Open bbodenmiller opened 9 years ago
@bbodenmiller By followed, do you mean the map pans to keep the real-time location within the view bounds when the location reaches the edge of the map? If so, then it's currently working as intended. We don't have a "follow" mode for OBA Android. In my past experience with other apps this actually isn't trivial to implement, either. I'll leave this open and change the ticket name to allow for a possible enhancement to implement a follow mode in the future. This would probably be most useful in the context of #25 for trip planning and #17 destination reminders.
I'm talking about following the users location and keeping it centered in the view. Like on Google Maps when you click the location button it follows your location until you pan the map. The current implementation of making sure the blue dot stays in view is certainly better than nothing.
I'm actually surprised you've had trouble implementing it as I seem to recall it being a built in feature in the library a few years ago. It looks like https://developers.google.com/maps/documentation/android-api/location under The My Location layer has the details on how to add. Looks like http://stackoverflow.com/questions/14489880/how-to-change-the-position-of-maps-apis-get-my-location-button has details on how to customize the button location.
We don't actually mess with the map camera at all in the current OBA Android implementation, other than initially zooming to your real-time location. So currently we don't make sure the blue dot stays in the view, either.
The built-in my location button you're linking to doesn't have the behavior of toggling to follow your location (at least the last version I've looked at, as of a few Play Services versions ago). You're on your own to implement moving the map camera to follow the location. The built-in button behavior is exactly the same as the current custom "My Location" Floating Action Button in OBA Android. Google decided to roll-their-own button for Google Maps, and haven't (to my knowledge) shared exactly how that is implemented.
The hard part for implementing following the user's location is that the map listeners don't tell you whether a map camera movement is a result of programmatically changing the map view (i.e., triggered by app code) or a result of the user dragging the map themselves. As a result, you don't know when to "release" the automated movement if the user tries to move the camera themselves, and the user ends up fighting with the app to get the map to reposition. You can see my attempt to implement tracking the user's location in this app. IMHO it ends up being awkward UX, and we're better off just allowing the user to reposition the map themselves. This could change if we start doing real-time nav, but for now IMHO the time required to implement and end result isn't worth it. Of course, if someone decides to implement this and open a PR to prove me wrong I'd welcome it :).
If we implement a "follow mode", we should also have the map re-center on the user's location if the app is backgrounded or killed while follow mode is still active - suggested in https://github.com/OneBusAway/onebusaway-android/issues/579#issuecomment-230537857.
In the Aug. 2016 release of Google Maps v2, there are new listeners that should allow us to determine if the user moved the map, or if we did from code, which should make it easier to implement this kind of "follow" mode.
From https://code.google.com/p/gmaps-api-issues/issues/detail?id=4636#c39:
The August 2016 release introduces a set of new camera change listeners for camera motion start, ongoing, and end events. You can also see why the camera is moving, whether it's caused by user gestures, built-in API animations or developer-controlled movements. For details, see the guide to camera change events: https://developers.google.com/maps/documentation/android-api/events#camera-change-events
Also, see the release notes: https://developers.google.com/maps/documentation/android-api/releases#august_1_2016
Note that moving to these new listeners may cause backwards compatibility issues with Amazon Maps API v2 - see https://github.com/OneBusAway/onebusaway-android/issues/648.
It appears that despite the location indicator showing the location as being followed it's not actually being followed: