I want to rotate marker as per bearing or sensor value received from Accelerometer to show the user where actually he is moving. I have set marker icon and flat value to true but its not working as required.
mCurrentLocationMarker.position(new LatLng(
LocationUtils.sLatitude, LocationUtils.sLongitude));
mCurrentLocationMarker.icon(icon);
mCurrentLocationMarker.flat(true);
mCurrentLocationMarker.rotation(LocationUtils.sBearing);
if (currentMarker != null) {
currentMarker.setPosition(new LatLng(
LocationUtils.sLatitude,
LocationUtils.sLongitude));
} else {
currentMarker = mGoogleMap
.addMarker(mCurrentLocationMarker);
}
animateCameraTo(true);
I have used this as marker.
I don't know why its not rotating as per user's direction. If anyone has any idea please kindly help me where i am making mistake.
LocationUtils.sBearing is the value of Bearing which i received from onLocationChanged or accelerometer.
Basically I want to make my marker same as google maps marker which shows user in which direction they are moving or turning.
In Kotlin by using Google SphericalUtil class we can get bearing by passing source and destination LatLngs like:
Then set this result 'bearing` to the marker like
Reference: https://developers.google.com/maps/documentation/android-sdk/utility/#spherical