-
Notifications
You must be signed in to change notification settings - Fork 35
/
directions.html
51 lines (48 loc) · 1.79 KB
/
directions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html lang="en">
<head>
<title>ORS-js lib examples</title>
<script type="module" src="../dist/ors-js-client.js"></script>
</head>
<body>
<div>
<h1>ORS-js lib examples</h1>
<section>
<h2>Driving car directions</h2>
<div id="driving-car-directions">
<script type='module'>
import apiKey from './apiKey.js'
window.onload = function() {
const node = document.getElementById("driving-car-directions")
const orsDirections = new Openrouteservice.Directions({
api_key: apiKey
})
orsDirections.calculate({
coordinates: [[8.690958, 49.404662], [8.687868, 49.390139]],
profile: "driving-car",
extra_info: ["waytype", "steepness"],
format: "json",
api_version: 'v2',
})
.then(function(json) {
// Add your own result handling here
let response = JSON.stringify(json, null, "\t")
console.log(response);
response = response.replace(/(\n)/g, '<br>');
response = response.replace(/(\t)/g, ' ');
node.innerHTML = "<h3>Response</h3><p>" + response + "</p>";
})
.catch(function(err) {
let response = JSON.stringify(err, null, "\t")
console.error(response);
response = response.replace(/(\n)/g, '<br>');
response = response.replace(/(\t)/g, ' ');
node.innerHTML = "<h3>Error</h3><p>" + response + "</p>";
})
}
</script>
</div>
</section>
</div>
</body>
</html>