Skip to content

Conversation

@LukasPaczos
Copy link

Added NAVIGATION_TRACKING_MODE_GPS and NAVIGATION_TRACKING_MODE_NORTH as camera tracking options that can be set via NavigationMapboxMap#updateCameraTrackingMode.

ezgif com-video-to-gif 5

Code used for the example:

    navigationView.retrieveNavigationMapboxMap().retrieveMap().addOnMapClickListener(new MapboxMap.OnMapClickListener() {

      private boolean isNorth;
      private Camera standardEngine = navigationView.retrieveMapboxNavigation().getCameraEngine();
      private Camera northEngine = new NorthCamera();

      @Override
      public void onMapClick(@NonNull LatLng point) {
        navigationView.retrieveNavigationMapboxMap().updateCameraTrackingMode(
          isNorth ? NavigationCamera.NAVIGATION_TRACKING_MODE_GPS : NavigationCamera.NAVIGATION_TRACKING_MODE_NORTH
        );
        navigationView.retrieveMapboxNavigation().setCameraEngine(
          isNorth ? standardEngine : northEngine
        );
        isNorth = !isNorth;
      }
    });

and

  private static class NorthCamera extends SimpleCamera {
    @Override
    public double tilt(RouteInformation routeInformation) {
      return 0;
    }
  }

@LukasPaczos LukasPaczos requested a review from danesfeder October 2, 2018 11:24
@LukasPaczos LukasPaczos force-pushed the lp-camera-tracking-north branch from 38f8f9c to 902be28 Compare October 2, 2018 11:25
@danesfeder danesfeder added ✓ ready for review feature New feature request. backwards incompatible Requires a SEMVER major version change. labels Oct 2, 2018
@danesfeder danesfeder added this to the 0.20.0 milestone Oct 2, 2018
Copy link
Contributor

@danesfeder danesfeder left a comment

Choose a reason for hiding this comment

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

@LukasPaczos this looks great! One minor comment to check before we merge, but I think we are in the clear regarding it.

return; //no need to recalculate these values
}
initialRoute = route;
routeCoordinates = generateRouteCoordinates(route);
Copy link
Contributor

Choose a reason for hiding this comment

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

@LukasPaczos can we double check that these routeCoordinates are still being used? I believe they are (for the route overview LatLngBounds) but just want to double check - thanks!

Copy link
Author

Choose a reason for hiding this comment

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

Looks like they are being used for the overview as you mentioned :)

@hurrba
Copy link

hurrba commented Oct 2, 2018

@LukasPaczos @danesfeder
it's nice to see that you finally have started on implementing this! however, there is a problem with the proposed solution: the puck is still in the bottom of the screen, which means that you have very poor overview when driving south. The puck should be in the middle of the screen when NAVIGATION_TRACKING_MODE_NORTH is enabled.

The only way we managed to solve this was to remove the wayname label. For some reason, this label prevents setting the puck in the middle of the screen. I haven't had time to look more into it in order to make a pull request, but perhaps it's an easy fix for you?

@danesfeder
Copy link
Contributor

@hurrba are you adjusting with the MapboxMap#setPadding? We use the top padding value here to "push" the puck to the bottom above the BottomSheet.

You should be able to set the tracking mode with this PR and at the same time use NavigationMapboxMap#retrieveMap#setPadding to updated the padding you desire (you can cache / then reset to our calculated padding with getPadding prior to doing this).

We could do this for you when you set the tracking mode, but that would couple the padding adjustment and other developers may not desire this same behavior.

@hurrba
Copy link

hurrba commented Oct 2, 2018

@danesfeder that seems to do the trick!
then my only comment is to perhaps add this to the documentation now that it's possible to set NAVIGATION_TRACKING_MODE_NORTH. :)

@Guardiola31337
Copy link
Contributor

@hurrba

then my only comment is to perhaps add this to the documentation now that it's possible to set NAVIGATION_TRACKING_MODE_NORTH. :)

Will be for sure! Thanks for the suggestion and for checking out the SDK!

@LukasPaczos LukasPaczos force-pushed the lp-camera-tracking-north branch from 902be28 to 9c2b954 Compare October 2, 2018 15:46
@danesfeder danesfeder force-pushed the lp-camera-tracking-north branch from 9c2b954 to dfbf812 Compare October 2, 2018 17:23
@LukasPaczos LukasPaczos merged commit ce34050 into master Oct 3, 2018
@LukasPaczos LukasPaczos deleted the lp-camera-tracking-north branch October 3, 2018 11:09
@danesfeder danesfeder mentioned this pull request Oct 5, 2018
11 tasks
@hurrba
Copy link

hurrba commented Oct 25, 2018

@LukasPaczos @danesfeder @Guardiola31337 my original comment is still relevant if using this when showing wayname. see #1465

@Guardiola31337 Guardiola31337 removed the backwards incompatible Requires a SEMVER major version change. label Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants