沿直线方向旋转图标

Rotate the icons in the direction of the line

我正在尝试使用来自 geoJson 文件的图标和坐标向线条添加方向,箭头不跟随线条这里是一个示例:Example

这是我用来转动箭头的 php 函数:

function getRotationAngle($long1, $lat1, $long2, $lat2) {

$latit1 = deg2rad($lat1);
$latit2 = deg2rad($lat2);
$longi1 = deg2rad($long1);
$longi2 = deg2rad($long2);

$dLon = $longi2 - $longi1;

$y = sin($dLon) * cos($latit1);
$x = cos($latit2) * sin($latit1) - sin($latit2) * cos($lati1) * cos($dLon);

$brng = atan2($y, $x) ;

$angle = $brng * 180 / pi();
$angle1 =fmod($angle + 180,180);
//echo "rotation angle =". $angle1."<br>";
return $angle1;
}

我希望箭头跟随由 geoJson 坐标制成的 lineString,角度作为特征保存在 geojosn 中

$angle = 360 - ((rad2deg(atan2($y, $x)) + 360) % 360);