Readme

Geocode a free-form description via the Nominatim API

The search API allows you to look up a location from a textual description or address. Nominatim supports structured and free-form search queries.

Docs: https://nominatim.org/release-docs/latest/api/Search/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export function nominatimSearch(params: Search): Promise<Place[]> {
return fetchJSON(
"https://nominatim.openstreetmap.org/search?" +
new URLSearchParams({
format: "json",
...params,
})
);
}
interface Search {
q?: string;
street?: string;
city?: string;
county?: string;
state?: string;
country?: string;
postalcode?: string;
}
interface Place {
place_id: number;
licence: string;
osm_type: string;
osm_id: number;
lat: string;
lon: string;
class: string;
type: string;
place_rank: number;
importance: number;
addresstype: string;
name: string;
display_name: string;
boundingbox: string[];
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.