Autocomplete API
Für API-Anbieter: Wenn Sie einen eigenen Autocomplete-Endpunkt bereitstellen, muss dieser folgendes Format liefern.
Erwartetes Format
Das Widget arbeitet intern mit diesem Format:
interface AutocompleteResponse {
suggestions: AutocompleteLocation[];
hasMore?: boolean;
}
interface AutocompleteLocation {
id: string;
name: string;
type: "station" | "stop" | "poi" | "address";
coordinates?: { lat: number; lng: number };
city?: string;
region?: string;
}
Unterstütztes API-Format
Das Widget unterstützt ein einfaches API-Format:
Beispiel-Request
POST https://api.example.com/autocomplete
{
"term": "Wald",
"types": ["stop", "poi", "address"],
"hash": "generated-sha1-hash"
}
Beispiel-Response
[
{
"id": "lb-148",
"type": "stop",
"title": "Lübeck, Friedhof Waldhusen"
},
{
"id": "1001",
"type": "poi",
"title": "Waldspielplatz"
},
{
"id": "54.198830,9.904580,Waldheim+am+Brahmsee",
"type": "address",
"title": "Waldheim am Brahmsee, Waldheim 1"
}
]
Location Types
- stop — Öffentliche Verkehrsmittel-Haltestellen
- poi — Points of Interest (Sehenswürdigkeiten, Geschäfte)
- address — Adressen mit Koordinaten im ID-Format
lat,lng,name
Das Widget extrahiert automatisch Stadt und Region aus dem Titel. Koordinaten werden aus Adress-IDs extrahiert.