Google Maps API — Google Maps Directions Service

Directions Service

Enable Directions API library

Include Maps JavaScript Library

<script src="https://maps.googleapis.com/maps/api/js?key=[YOUR_API_KEY]">

Make A Request To Directions Service

const directionsService = new google.maps.DirectionsService();
directionsService.route();

DirectionsRequest

directionsService.route(
{
origin: "190 Main Street, Ottawa, Canada",
destination: "290 First Avenue, Ottawa, Canada",
travelMode: "DRIVING"
}
)

Response Object

directionsService.route(
{
origin: "190 Main Street, Ottawa, Canada",
destination: "290 First Avenue, Ottawa, Canada",
travelMode: "DRIVING"
},
(response, status) => {
console.log(response);
console.log(status);
}
)

Instructor/Owner of SoftAuthor! http://softauthor.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store