# Reverse Geocoding

> GET /v1/reverse beantwortet die umgekehrte Frage. Du gibst eine Koordinate, Findort sagt dir, welche Adresse oder welcher Ort dort liegt.

Source: https://findort.ch/de/docs/reverse/

## Anfrage

```http
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](https://findort.ch/de/docs/suche/#parameter), 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

```bash
  -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](https://findort.ch/de/docs/antwort/). Das nächstgelegene Resultat kommt zuerst. Liegt im Radius nichts, ist `results` leer.

## Mit dem Standort im Browser

```js

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 ?? '';
});
```
