Reverse Geocoding
GET /v1/reverse beantwortet die umgekehrte Frage. Du gibst eine Koordinate, Findort sagt dir, welche Adresse oder welcher Ort dort liegt.
Anfrage
HTTP
GET https://api.findort.ch/v1/reverse?lat=46.9465&lon=7.4443&limit=1
Authorization: Bearer pk_…Typische Einsätze: der Knopf «Meinen Standort verwenden» in einem Formular, ein Klick auf eine Karte oder GPS-Punkte aus einer App, die eine lesbare Adresse brauchen.
Parameter
| Parameter | Typ | Vorgabe | Beschreibung |
|---|---|---|---|
lat | Zahl, Pflicht | Breitengrad, -90 bis 90 | |
lon | Zahl, Pflicht | Längengrad, -180 bis 180 | |
radius | Zahl | Suchradius in Kilometern, 0.01 bis 50. Begrenzt die Suche auf diesen Umkreis. | |
limit | Zahl | 5 | Anzahl Resultate, 1 bis 20 |
lang | Text | Landessprache | de, fr, it oder en |
types | Liste | alle Typen | wie bei der Suche, zum Beispiel types=address |
key | Text | API-Key, falls kein Authorization-Header möglich ist |
country, near und bbox gibt es hier nicht, die Koordinate legt den Ort schon fest.
Beispiel
Shell
curl "https://api.findort.ch/v1/reverse?lat=46.9465&lon=7.4443&limit=1&types=address" \
-H "Authorization: Bearer sk_…"JSON
{
"results": [
{
"id": "N3797624451",
"label": "Bundesplatz 3, 3011 Bern",
"name": "Bundesplatz 3",
"type": "address",
"category": "place:house",
"address": {
"street": "Bundesplatz",
"housenumber": "3",
"postcode": "3011",
"city": "Bern",
"state": "Bern",
"country": "Schweiz",
"countryCode": "CH"
},
"location": { "lat": 46.94652, "lon": 7.44436 }
}
],
"attribution": "© OpenStreetMap contributors, ODbL"
}Die Antwort hat dasselbe Format wie bei der Suche, siehe Antwortformat. Das nächstgelegene Resultat kommt zuerst. Liegt im Radius nichts, ist results leer.
Mit dem Standort im Browser
JavaScript
import { Findort } from 'findort';
const findort = new Findort('pk_…', { lang: 'de' });
navigator.geolocation.getCurrentPosition(async ({ coords }) => {
const [place] = await findort.reverse(coords.latitude, coords.longitude, { limit: 1, types: 'address' });
document.querySelector('#address').value = place?.label ?? '';
});