Calculate the direction (heading) in Google Maps API V3

whdals0 picture whdals0 · Oct 21, 2013 · Viewed 8k times · Source

From origin to destination, I would like to know the direction of.

Simply want to know which direction is in the angle values​​.

In the image above, the angle value will be probably between 350-360. (Image source : https://maps.google.com/maps?saddr=Dr+NS+Hardikar+Rd&daddr=Rithala+Metro+Station,+Rithala+Rd,+Sector+12,+Rohini,+New+Delhi,+Delhi,+India&geocode=FYfstQEdJn-YBA%3BFY8-tgEd3Y-YBCnlvvwRTAENOTHixeyZbhPwSA&sll=28.697665,77.11956&sspn=0.062715,0.11055&hl=en)

I can't upload image. sorry.

How do I calculate?

Answer

Dr.Molle picture Dr.Molle · Oct 21, 2013

Use google.maps.geometry.spherical.computeHeading() with start_location of the first leg and end_location of the last leg as arguments.