2 import { page, results_store } from '../lib/stores.js';
3 import { fetch_from_api, update_html_title } from '../lib/api_utils.js';
5 import Header from '../components/Header.svelte';
6 import SearchSection from '../components/SearchSection.svelte';
7 import ResultsList from '../components/ResultsList.svelte';
8 import Map from '../components/Map.svelte';
10 let api_request_params;
11 let bStructuredSearch;
14 function loaddata(search_params) {
17 api_request_params = {
18 q: search_params.get('q'),
19 street: search_params.get('street'),
20 city: search_params.get('city'),
21 county: search_params.get('county'),
22 state: search_params.get('state'),
23 country: search_params.get('country'),
24 postalcode: search_params.get('postalcode'),
25 polygon_geojson: Nominatim_Config.Search_AreaPolygons ? 1 : 0,
26 viewbox: search_params.get('viewbox'),
27 bounded: search_params.get('bounded'),
28 dedupe: search_params.get('dedupe'),
29 'accept-language': search_params.get('accept-language'),
30 countrycodes: search_params.get('countrycodes'),
31 limit: search_params.get('limit'),
32 polygon_threshold: search_params.get('polygon_threshold'),
33 exclude_place_ids: search_params.get('exclude_place_ids'),
37 let anyStructuredFieldsSet = (api_request_params.street
38 || api_request_params.city
39 || api_request_params.county
40 || api_request_params.state
41 || api_request_params.country
42 || api_request_params.postalcode);
44 if (api_request_params.q || anyStructuredFieldsSet) {
45 fetch_from_api('search', api_request_params, function (data) {
46 results_store.set(data);
48 update_html_title('Result for ' + api_request_params.q);
50 if (anyStructuredFieldsSet) {
51 document.querySelector(".nav-tabs a[href='#structured']").click();
52 document.querySelector('input[name=street]').focus();
54 document.querySelector('input[name=q]').focus();
58 results_store.set(undefined);
64 if (pageinfo.tab === 'search') {
65 loaddata(pageinfo.params);
71 <SearchSection api_request_params={api_request_params} bStructuredSearch={bStructuredSearch} />
76 <ResultsList bind:current_result reverse_search={false} />
78 <div id="map-wrapper">
79 <Map {current_result} display_minimap={true} />
96 height: calc(100vh - 250pt);
104 @media (max-width: 768px) {