2

I need to get travel time by plane between two locations. In Distance Matrix API there is no Travel Mode like "flight" - https://developers.google.com/maps/documentation/javascript/distancematrix#travel_modes

Any suggestions?

2 Answers 2

2

Unfortunately there is no easy way to do this. However, you could do a trick and estimate the flight time by using geocoding and the geometry library. At least if you don't need real flight data.

The steps would be:

  1. Transform origin and destination from String to LatLng (Geocoding API)
  2. Create markers for each location. (Geometry lib)
  3. Calculate airline distance using computeDistanceBetween (like this: google.maps.geometry.spherical.computeDistanceBetween(path1, path2))
  4. Calculate approximate flight time using average airplane speed.

Hope this helps.

0

This is sort of a work-around, but an easy one.

Use the measure distance tool in google maps, then for flight time of regular commercial airliners, divide the distance in miles by 500mph to get flight time in hours. For a small propeller plane (like a cessna), use 165mph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.