Important: Please read the Qt Code of Conduct -

About the bearing calculation for map

  • Dear All,

    I'm trying to make navigate. But I have no idea how to use the bearing feature. How should I calculate the bearing, what conditions should I consider when calculating, and what should my calculation criteria be?

    Any idea on this issue?


  • Lifetime Qt Champion


    What do you mean by "make navigate" ?

  • @SGaist

    Sorry , I mean navigation. I've already solved the problem.

    I am using the following JavaScript code.

            var firstLatitude=deg2rad(latitudeArray[latitudeArray.length-2]);
            var firstLongtitude=deg2rad(longtitudeArray[longtitudeArray.length-2]);
            var endLatitude=deg2rad(latitudeArray[latitudeArray.length-1]);
            var endLongtitude=deg2rad(longtitudeArray[longtitudeArray.length-1]);
            var diffLongtitude=(endLongtitude-firstLongtitude);
            var x=Math.sin(diffLongtitude)*Math.cos(endLatitude);
            var y=Math.cos(firstLatitude)*Math.sin(endLatitude)-Math.sin(firstLatitude)*Math.cos(endLatitude)*Math.cos(diffLongtitude);
            var bearing =(rad2deg(Math.atan2(x,y)));

Log in to reply