androidheremapsheremaps-android-sdkheremap-navigation

Making the location indicator in turn-by-turn navigation always look forward even when deviating from the route?


Is it possible to ensure that the location indicator doesn't keep pointing back to the route while you are deviating from it? It makes it very hard to see what's in front of the user as when camera tracking mode is turned on, it locks the camera to the location indicator's direction (e.g indicating to go back -> makes the camera look back),

What I want is to be able point the location indicator to wherever the user is going towards, so if they do a right turn and it just happens to deviate from the route, I want it to continue looking forward and not backwards to the route.


Solution

  • Figured it out.

    Since I use a custom location provider, I have to create a custom "HERE Location" object, but there's a nice property in this object to set its bearings; "setBearingInDegrees", simply find the user's bearings and set it using this setter.

    e.g:

    var bearing = 0.0;
        
    Location location = new Location.Builder()
                    .setCoordinates(geoCoordinates)
                    .setBearingInDegrees(bearing)
                    .build();
    

    You would then set this 'location' back to the VisualNavigator so that it shows this location on the default indicator using its method 'onLocationUpdated'.

    Even if you're on camera tracking mode, this will make you face the bearing you set in this location, which is perfect and exactly what I needed.

    More information is found in the 'Add a Location Indicator' section: https://developer.here.com/documentation/android-sdk-navigate/4.10.4.0/dev_guide/topics/map-items.html