Created
February 21, 2023 13:16
-
-
Save TravelTime-Frontend/6dfc0a1c8b268ded6d989d54ba20a9cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The request for Time Map. Reference: http://docs.traveltimeplatform.com/reference/time-map/ | |
var request = { | |
// This will be a search where we depart a specified time. | |
departure_searches: [{ | |
// The id is useful when you send multiple searches in one request. Since we create only one search it doesn't matter much since we expect only one result. | |
id: "first_location", | |
// The coordinates for the departure location in a hash. { lat: <lat>, lng: <lng> } | |
"coords": coords, | |
// The transportation type for this search. We will be using public transport. | |
transportation: { | |
type: "public_transport" | |
}, | |
// The departure time in an ISO format. | |
departure_time: departureTime, | |
// Travel time in seconds. | |
travel_time: travelTime | |
}], | |
// We will not be creating any shapes with a specified arrival time in this example so the array is empty. | |
arrival_searches: [] | |
}; | |
$.ajax({ | |
// The URL for the Time Map endpoint. | |
url: "http://api.traveltimeapp.com/v4/time-map", | |
// We will need to send a POST request. | |
type: "post", | |
// The authentification headers. | |
"headers": headers, | |
// The request body in a JSON format. | |
data: JSON.stringify(request), | |
contentType: "application/json; charset=UTF-8", | |
success: function (data) { | |
// Here we handle the response from Time Map | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment