-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: rizwan <[email protected]>
- Loading branch information
1 parent
1f630c4
commit 634eab6
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 snapping</h2> | ||
<div id="driving-car-snap"> | ||
<script type='module'> | ||
import apiKey from './apiKey.js' | ||
window.onload = function() { | ||
const node = document.getElementById("driving-car-snap") | ||
|
||
const Snap = new Openrouteservice.Snap({ | ||
api_key: apiKey | ||
}) | ||
|
||
Snap.calculate({ | ||
locations: [[8.690958, 49.404662], [8.687868, 49.390139]], | ||
radius: 300, | ||
profile: "driving-car", | ||
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> |