Request

origins: Vancouver+BC|Seattle destinations: San+Francisco|Victoria+BC mode: transit transit_mode: train key: API_KEY

URL

https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=transit&transit_mode=train&key=YOUR_API_KEY
XML

Response

<?xml version="1.0" encoding="UTF-8"?> <DistanceMatrixResponse> <status>OK</status> <origin_address>Vancouver, BC, Canada</origin_address> <origin_address>Seattle, WA, USA</origin_address> <destination_address>San Francisco, CA, USA</destination_address> <destination_address>Victoria, BC, Canada</destination_address> <row> <element> <status>OK</status> <duration> <value>145285</value> <text>1 day 16 hours</text> </duration> <distance> <value>1731459</value> <text>1,731 km</text> </distance> </element> <element> <status>OK</status> <duration> <value>71004</value> <text>19 hours 43 mins</text> </duration> <distance> <value>267181</value> <text>267 km</text> </distance> </element> </row> <row> <element> <status>OK</status> <duration> <value>87626</value> <text>1 day 0 hours</text> </duration> <distance> <value>1479935</value> <text>1,480 km</text> </distance> </element> <element> <status>OK</status> <duration> <value>53884</value> <text>14 hours 58 mins</text> </duration> <distance> <value>161703</value> <text>162 km</text> </distance> </element> </row> </DistanceMatrixResponse>
JSON

Response

{ "destination_addresses" : [ "San Francisco, CA, USA", "Victoria, BC, Canada" ], "origin_addresses" : [ "Vancouver, BC, Canada", "Seattle, WA, USA" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "1,731 km", "value" : 1731438 }, "duration" : { "text" : "1 day 16 hours", "value" : 145285 }, "status" : "OK" }, { "distance" : { "text" : "267 km", "value" : 267181 }, "duration" : { "text" : "19 hours 43 mins", "value" : 71004 }, "status" : "OK" } ] }, { "elements" : [ { "distance" : { "text" : "1,480 km", "value" : 1479935 }, "duration" : { "text" : "1 day 0 hours", "value" : 87626 }, "status" : "OK" }, { "distance" : { "text" : "162 km", "value" : 161703 }, "duration" : { "text" : "14 hours 58 mins", "value" : 53884 }, "status" : "OK" } ] } ], "status" : "OK" }