Calculate the distance between two addresses!
https://distance-calculation.netlify.com/
This project was created to calculate the distance between two addresses, and return the view of the distance, travel time and the origin and destination markers(pin) on the map.
API's used
- Distance Matrix from Google Maps API
- Geocoding from Google Maps API
It is important to note that when thinking about some new features, I was able to do a search in which I can use the Directions API to return distance, duration, latitude and longitude, in addition to the polylines, which allow me to define in addition to the markers, the way to be traveled between origin and destination. (But it is for a next project...)
It is possible to consume the DistanceCalculation API for this project by sending as parameters:
- origins (source address)
- destinations (destination address)
- mode (walking, driving or bicycling)
Make a request (POST) in https://distance-calculation.herokuapp.com/distance
Example:
{
"origins": "São Paulo, SP",
"destinations": "Rio de Janeiro, RJ",
"mode": "driving"
}
The return will come with the following properties:
{
"distance": "434 km",
"duration": "5 hours 34 mins",
"origins": {
"lat": -23.5505199,
"lng": -46.63330939999999
},
"destinations": {
"lat": -22.9068467,
"lng": -43.1728965
},
"zoom": 8,
"center": {
"lat": -23.2286833,
"lng": -44.90310294999999
}
}
Distributed under the MIT License.
Lucas França - https://lucasfrancaid.com.br/