Erste Route
Erste Route
Anfrage
Koordinaten sind immer lon,lat, getrennt durch ;.
curl -s -H "Authorization: Bearer DEIN_TOKEN" "https://api.mapx.at/v1/directions/driving/16.3725,48.2085;15.3294,48.2272?overview=false" \
| jq '.routes[0] | {distance, duration}'distance ist in Metern, duration in Sekunden. Weitere Profile: driving-truck, cycling, walking. Siehe den Navigation-Guide.
Auf der Karte zeichnen
Mit der Karte aus Erste Karte in map:
const url = "https://api.mapx.at/v1/directions/driving/16.3725,48.2085;15.3294,48.2272?overview=simplified";
const route = (await (await fetch(url, { headers: { Authorization: "Bearer DEIN_TOKEN" } })).json()).routes[0];
map.on("load", () => {
map.addSource("route", { type: "geojson", data: { type: "Feature", geometry: route.geometry } });
map.addLayer({ id: "route", type: "line", source: "route", paint: { "line-color": "#1d5bd8", "line-width": 5 } });
map.fitBounds([[15.3294, 48.2085], [16.3725, 48.2272]], { padding: 40 });
});Nächste Schritte
- Navigation-Guide: Lkw, Rad, Maut, Alternativen
- Directions API