Skip to content

Google Directions API call notes

Zachary Lopez edited this page Jan 22, 2015 · 4 revisions

more info: https://developers.google.com/maps/documentation/javascript/directions

A google direction request:

https://maps.googleapis.com/maps/api/directions/json?origin=944+Market+Street,San+Francisco,CA&destination=174+Ellis+Street,San+Francisco,CA&mode=walking&key=API_key

same request with lat,long instead of addresses:

https://maps.googleapis.com/maps/api/directions/json?origin=37.7854137,-122.4085524&destination=37.7853691,-122.4090658&mode=walking&key=API_key

the return object in json:

{
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 37.7854137, "lng" : -122.4085524

}, "southwest" : {

"lat" : 37.7834319, "lng" : -122.4090658

}

}, "copyrights" : "Map data ©2015 Google", "legs" : [

{
"distance" : {
"text" : "0.2 mi", "value" : 268

}, "duration" : {

"text" : "4 mins", "value" : 218

}, "end_address" : "174 Ellis Street, San Francisco, CA 94102, USA", "end_location" : {

"lat" : 37.7853691, "lng" : -122.4090658

}, "start_address" : "944 Market Street, San Francisco, CA 94102, USA", "start_location" : {

"lat" : 37.7834319, "lng" : -122.4088122

}, "steps" : [

{
"distance" : {
"text" : "105 ft", "value" : 32

}, "duration" : {

"text" : "1 min", "value" : 27

}, "end_location" : {

"lat" : 37.7836379, "lng" : -122.4085524

}, "html_instructions" : "Head u003cbu003enortheastu003c/bu003e on u003cbu003eMarket Stu003c/bu003e toward u003cbu003eTurk Stu003c/bu003e", "polyline" : {

"points" : "mqreF`~bjVMO[c@"

}, "start_location" : {

"lat" : 37.7834319, "lng" : -122.4088122

}, "travel_mode" : "WALKING"

}, {

"distance" : {
"text" : "299 ft", "value" : 91

}, "duration" : {

"text" : "1 min", "value" : 73

}, "end_location" : {

"lat" : 37.7844507, "lng" : -122.4086873

}, "html_instructions" : "Turn u003cbu003eleftu003c/bu003e toward u003cbu003eEddy Stu003c/bu003e", "maneuver" : "turn-left", "polyline" : {

"points" : "wrreFl|bjVaDZ"

}, "start_location" : {

"lat" : 37.7836379, "lng" : -122.4085524

}, "travel_mode" : "WALKING"

}, {

"distance" : {
"text" : "33 ft", "value" : 10

}, "duration" : {

"text" : "1 min", "value" : 7

}, "end_location" : {

"lat" : 37.78446599999999, "lng" : -122.4085706

}, "html_instructions" : "Turn u003cbu003erightu003c/bu003e onto u003cbu003eEddy Stu003c/bu003e", "maneuver" : "turn-right", "polyline" : {

"points" : "ywreFh}bjVCW"

}, "start_location" : {

"lat" : 37.7844507, "lng" : -122.4086873

}, "travel_mode" : "WALKING"

}, {

"distance" : {
"text" : "351 ft", "value" : 107

}, "duration" : {

"text" : "1 min", "value" : 87

}, "end_location" : {

"lat" : 37.7854137, "lng" : -122.4087533

}, "html_instructions" : "Turn u003cbu003eleftu003c/bu003e onto u003cbu003eCyril Magnin Stu003c/bu003e", "maneuver" : "turn-left", "polyline" : {

"points" : "}wreFp|bjVMBkBRaAJ"

}, "start_location" : {

"lat" : 37.78446599999999, "lng" : -122.4085706

}, "travel_mode" : "WALKING"

}, {

"distance" : {
"text" : "92 ft", "value" : 28

}, "duration" : {

"text" : "1 min", "value" : 24

}, "end_location" : {

"lat" : 37.7853691, "lng" : -122.4090658

}, "html_instructions" : "Turn u003cbu003eleftu003c/bu003e onto u003cbu003eEllis Stu003c/bu003eu003cdiv style="font-size:0.9em"u003eDestination will be on the rightu003c/divu003e", "maneuver" : "turn-left", "polyline" : {

"points" : "y}reFt}bjVBh@BT"

}, "start_location" : {

"lat" : 37.7854137, "lng" : -122.4087533

}, "travel_mode" : "WALKING"

}

], "via_waypoint" : []

}

], "overview_polyline" : {

"points" : "mqreF`~bjVi@s@aDZCWyBVaAJBh@BT"

}, "summary" : "Cyril Magnin St", "warnings" : [

"Walking directions are in beta. Use caution – This route may be missing sidewalks or pedestrian paths."

], "waypoint_order" : []

}

], "status" : "OK"

}