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

ParameterTypVorgabeBeschreibung
latZahl, PflichtBreitengrad, -90 bis 90
lonZahl, PflichtLängengrad, -180 bis 180
radiusZahlSuchradius in Kilometern, 0.01 bis 50. Begrenzt die Suche auf diesen Umkreis.
limitZahl5Anzahl Resultate, 1 bis 20
langTextLandessprachede, fr, it oder en
typesListealle Typenwie bei der Suche, zum Beispiel types=address
keyTextAPI-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 ?? '';
});