Open zjffun opened 5 years ago
wow dude @zjffun, you are a live saver. thanks for the PR
@MinSomai Glad this can help you :)
BTW, arrow was pointing up when zooming in/out.
We are using turfjs and this seems to fix the issue.
Putting the code here in case someone faces the same issue.
Thanks again for the PR.
_updateRotation: function () {
const cord1 = turf.point([this._currentLine[0].lng, this._currentLine[0].lat]);
const cord2 = turf.point([this._currentLine[1].lng, this._currentLine[1].lat]);
let bearing = turf.bearing(cord1, cord2);
this.setRotationAngle(bearing / 2 + 0 / 2); // 0/2 <- here 0, is for configuration/rotation offset.
this.setRotationOrigin(this.options.rotationOrigin);
// if (this._rotationAngle) {
// this._icon.style[L.DomUtil.TRANSFORM + "Origin"] = this.options.rotationOrigin;
// this._icon.style[L.DomUtil.TRANSFORM] +=
// " rotateZ(" + (this.options.initialRotationAngle + this._rotationAngle) + "deg)";
// }
},
Add the function to rotate markers along the route, which can be used to show more cool track animations