flutter_animarker
flutter_animarker copied to clipboard
Rotating clockwise >180 degrees when marker can loop over to rotate counter clockwise.
When a marker's bearing should go over 0 to rotate counter-clockwise (e.g. when going from 5 degrees to 355 degrees when taking a left turn), the marker instead rotates clockwise, spanning 350 degrees when it could have rotated 10 degrees counter clockwise.
The issue only occurs when the marker's bearing must "loop over" the zero mark.
yes exactly, it tries to avoid looping over the 0 mark.
@efea-umich Did you manage to find a workaround to this?
Any update on this?
Well, I found a workaround on this.
I just used simple if-else condition
void _locationListener() {
if (description.latLngListener != null) {
/// check it first weather rotation is grater than 180 or not
if ((wrapper.locationTween.begin.bearing -
wrapper.locationTween.end.bearing)
.abs() >
180) {
var bearing = wrapper.locationTween.begin.bearing;
/// calculate total rotation complated
final complatedRotation = (bearing - _bearingAnimation.value).abs();
/// cheking for clockwise or anti clockwise
if (wrapper.locationTween.begin.bearing >
wrapper.locationTween.end.bearing) {
// clock wise
bearing = bearing + complatedRotation;
if (bearing > 360) bearing = bearing - 360;
/// as we are not using default animation value so our rotation will complate ealier,
/// and it will try to go further rotatio.
/// so we need to keep our bearing between given two points(Start and end points)
if (bearing > wrapper.locationTween.begin.bearing ||
bearing < wrapper.locationTween.end.bearing) {
description
.latLngListener!(_proxyAnim.value.copyWith(bearing: bearing));
} else {
description.latLngListener!(_proxyAnim.value
.copyWith(bearing: wrapper.locationTween.end.bearing));
}
} else {
/// anti-clock wise
bearing = bearing - complatedRotation;
if (bearing < 0) bearing = 360 - bearing.abs();
if (bearing < wrapper.locationTween.begin.bearing ||
bearing > wrapper.locationTween.end.bearing) {
description
.latLngListener!(_proxyAnim.value.copyWith(bearing: bearing));
} else {
description.latLngListener!(_proxyAnim.value
.copyWith(bearing: wrapper.locationTween.end.bearing));
}
}
} else {
description.latLngListener!(value);
}
}
}
at this function
Thanks. Any idea how to implement polyline with the marker moving?
Thanks @manishrelani