Skip to content

Commit

Permalink
Test for time travel api implimentation
Browse files Browse the repository at this point in the history
  • Loading branch information
beachatel committed Oct 11, 2024
1 parent a8841cd commit 984b768
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 28 deletions.
5 changes: 5 additions & 0 deletions Projects/15MC/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Application ID = "5036f84f"

Application Keys = "45a4de942f1b32a4be715b415c4e3bcf"

https://api.traveltimeapp.com/v4/time-map
2 changes: 2 additions & 0 deletions Projects/15MC/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
crossorigin="anonymous" referrerpolicy="no-referrer"></script> -->

<script src="sketch.js"></script>
<script src="isoschrone.js"></script>
<script src="isochrone.json"></script>
<!-- <script src="index.js"></script> -->

</body>
Expand Down
27 changes: 0 additions & 27 deletions Projects/15MC/index.js

This file was deleted.

54 changes: 54 additions & 0 deletions Projects/15MC/isochrone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("X-Application-Id", "{{5036f84f}}");
myHeaders.append("X-Api-Key", "{{45a4de942f1b32a4be715b415c4e3bcf}}");

const raw = JSON.stringify({
"departure_searches": [
{
"id": "public transport from Trafalgar Square",
"coords": {
"lat": 51.507609,
"lng": -0.128315
},
"transportation": {
"type": "public_transport"
},
"departure_time": "{{departure_time}}",
"travel_time": 900
}
],
"arrival_searches": [
{
"id": "public transport to Trafalgar Square",
"coords": {
"lat": 51.507609,
"lng": -0.128315
},
"transportation": {
"type": "public_transport"
},
"arrival_time": "{{arrival_time}}",
"travel_time": 900,
"range": {
"enabled": true,
"width": 3600
}
}
]
});

const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};

fetch("https://api.traveltimeapp.com/v4/time-map", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));

// push to git
35 changes: 35 additions & 0 deletions Projects/15MC/isochrone.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

{
"departure_searches": [
{
"id": "public transport from Trafalgar Square",
"coords": {
"lat": 51.507609,
"lng": -0.128315
},
"transportation": {
"type": "public_transport"
},
"departure_time": "{{departure_time}}",
"travel_time": 900
}
],
"arrival_searches": [
{
"id": "public transport to Trafalgar Square",
"coords": {
"lat": 51.507609,
"lng": -0.128315
},
"transportation": {
"type": "public_transport"
},
"arrival_time": "{{arrival_time}}",
"travel_time": 900,
"range": {
"enabled": true,
"width": 3600
}
}
]
}
3 changes: 2 additions & 1 deletion Projects/15MC/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ body{


#map{

margin: 50px;
top: 5vh;
height: 80vh;
width: 80vw;

}
1 change: 1 addition & 0 deletions Projects/15MC/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ if ("geolocation" in navigator) {
}



0 comments on commit 984b768

Please sign in to comment.