Creating a distance matrix for the given locations
The Google Maps JavaScript API carries some interesting and particularly helpful properties, one of them being the Distance Matrix Service. Using this service, you can compute the travel time and distance between multiple origins and destination locations.
This is especially useful when you want to have a one-to-one report of your travel nodes, be it a delivery business or only a summertime holiday. This service gives you the travel time and distances within your choice of travel mode (driving, walking, and cycling); you can see the results oriented for each origin and destination.
It is worth noting that the output of this service cannot be mapped onto the base maps; you can have the information about the travel time and duration, but for the directions, you have to use the Directions service, explained in detail in the Getting a direction for the given locations recipe later in this chapter.
In this recipe, we will locate the origin and destination...