Search code examples
javascriptgoogle-mapsgeolocationgeo

How to calculate time difference between two longitudes and latitudes distance


Basically what I wanted to know is, how long will it take to travel from location A to B? I've the location A longitudes and latitudes, and B latitudes and longitudes.

I did lot of searching on Google but couldn't find a proper answer.

Thanks in advance.


Solution

  • You can calculate the distance between 2 sets of coordinates in a line using formulate. You can find the codes for several programming languages in https://www.geodatasource.com/developers. From the distance, you can estimate the travel time using average speed.

    If you want to have accurate travel time, you need more real time information such as traffic conditions, current travel speed and route distance.