Add viewbox-bounded search and enable Dutch quick-search chips

- Pass the currently visible map bounds as a Nominatim viewbox so
  results are restricted to what the user can see (bounded=1).
- Increase default result limit from 8 to 20.
- Enable the quick-search chip row with localized Dutch labels
  (Supermarkt, Café, Kroeg, Camping, Park, Restaurant, Vegan,
  Hotel, Parkeerplek).
This commit is contained in:
2026-08-21 14:10:30 +02:00
parent 51f2eb8e1d
commit 439d389a44
2 changed files with 72 additions and 16 deletions

23
app.py
View File

@@ -60,13 +60,34 @@ def search():
params = { params = {
"q": query, "q": query,
"format": "jsonv2", "format": "jsonv2",
"limit": 8, "limit": 20,
"addressdetails": 1, "addressdetails": 1,
"extratags": 1, "extratags": 1,
"namedetails": 1, "namedetails": 1,
"dedupe": 1, "dedupe": 1,
} }
# Restrict results to the area currently visible on the map.
# Expected format: "left,top,right,bottom" (lon,lat pairs).
viewbox = request.args.get("viewbox", "").strip()
if viewbox:
parts = [p.strip() for p in viewbox.split(",")]
if len(parts) == 4:
try:
left, top, right, bottom = (
float(p) for p in parts
)
params["viewbox"] = "{},{},{},{}".format(
left, top, right, bottom
)
params["bounded"] = 1
except ValueError:
pass
try: try:
results = nominatim_request( results = nominatim_request(
NOMINATIM_SEARCH_URL, NOMINATIM_SEARCH_URL,

View File

@@ -699,51 +699,72 @@
<div class="bottom-ui"> <div class="bottom-ui">
<!--<div class="chips"> <div class="chips">
<button <button
class="chip" class="chip"
data-search="restaurants" data-search="supermarket"
> >
🍴 Restaurants 🛒 Supermarkt
</button> </button>
<button <button
class="chip" class="chip"
data-search="hotels" data-search="cafe"
> >
🛏 Hotels ☕ Café
</button> </button>
<button <button
class="chip" class="chip"
data-search="attractions" data-search="pub"
> >
📷 Attractions 🍺 Kroeg
</button> </button>
<button <button
class="chip" class="chip"
data-search="museums" data-search="camping"
> >
🏛 Museums ⛺ Camping
</button> </button>
<button <button
class="chip" class="chip"
data-search="public transport" data-search="park"
> >
🚆 Public transport 🌳 Park
</button> </button>
<button <button
class="chip" class="chip"
data-search="pharmacies" data-search="restaurant"
> >
💊 Pharmacies 🍴 Restaurant
</button> </button>
</div>--> <button
class="chip"
data-search="vegan restaurant"
>
🥗 Vegan
</button>
<button
class="chip"
data-search="hotel"
>
🛏 Hotel
</button>
<button
class="chip"
data-search="parking"
>
🅿️ Parkeerplek
</button>
</div>
<div class="search-box"> <div class="search-box">
@@ -944,6 +965,18 @@
clearMarkers(); clearMarkers();
// Build a viewbox from the currently visible map area so
// results are restricted to what the user can see.
const visibleBounds = map.getBounds();
const viewbox = [
visibleBounds.getWest(),
visibleBounds.getNorth(),
visibleBounds.getEast(),
visibleBounds.getSouth()
].join(",");
try { try {
const response = const response =
@@ -951,7 +984,9 @@
"/search?q=" + "/search?q=" +
encodeURIComponent( encodeURIComponent(
query + ", " query + ", "
) ) +
"&viewbox=" +
encodeURIComponent(viewbox)
); );