Calculate angle between two Latitude/Longitude points

后端 未结 17 1412
故里飘歌
故里飘歌 2020-12-07 17:51

Is there a way to calculate angle between two Latitude/Longitude points?

What I am trying to achieve is to know where the user is heading. For example, user is head

17条回答
  •  旧时难觅i
    2020-12-07 18:20

    You just can use the google maps computeHeading:

    var point1 = new google.maps.LatLng(lat1, lng1);
    var point2 = new google.maps.LatLng(lat2, lng2);
    var heading = google.maps.geometry.spherical.computeHeading(point1,point2);
    

提交回复
热议问题