Zum Inhalt springen

Beispielanwendungen

Routenberechnung mit Python

import requests
url = "https://valhalla.pixelmap.at/route"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
"locations": [
{"lat": 46.6249, "lon": 14.3050}, # Klagenfurt
{"lat": 48.2082, "lon": 16.3738} # Wien
],
"costing": "auto",
"directions_options": {
"language": "de-DE",
"units": "kilometers"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())

Routenberechnung mit JavaScript (Fetch API)

const url = "https://valhalla.pixelmap.at/route";
const data = {
"locations": [
{ "lat": 46.6249, "lon": 14.3050 }, // Klagenfurt
{ "lat": 48.2082, "lon": 16.3738 } // Wien
],
"costing": "auto",
"directions_options": {
"language": "de-DE",
"units": "kilometers"
}
};
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_TOKEN'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => console.log(data));