From 439d389a4462bc6cd1d58610faf2e9c45e9cc7d3 Mon Sep 17 00:00:00 2001 From: bramval Date: Fri, 21 Aug 2026 14:10:30 +0200 Subject: [PATCH] Add viewbox-bounded search and enable Dutch quick-search chips MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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). --- app.py | 23 +++++++++++++++- templates/index.html | 65 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/app.py b/app.py index a3b8907..82a063b 100644 --- a/app.py +++ b/app.py @@ -60,13 +60,34 @@ def search(): params = { "q": query, "format": "jsonv2", - "limit": 8, + "limit": 20, "addressdetails": 1, "extratags": 1, "namedetails": 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: results = nominatim_request( NOMINATIM_SEARCH_URL, diff --git a/templates/index.html b/templates/index.html index 8dfae32..0859676 100644 --- a/templates/index.html +++ b/templates/index.html @@ -699,51 +699,72 @@
- + + + + + + +