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.has('dedupe') || search_params.get('dedupe') === '1') ? 1 : 0,
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 if (anyStructuredFieldsSet) {
49 update_html_title('Result for ' + [
50 api_request_params.street,
51 api_request_params.city,
52 api_request_params.county,
53 api_request_params.state,
54 api_request_params.country,
55 api_request_params.postalcode
56 ].filter((text) => text && text.length > 1).join(', '));
58 document.querySelector(".nav-tabs a[href='#structured']").click();
59 document.querySelector('input[name=street]').focus();
61 update_html_title('Result for ' + api_request_params.q);
63 document.querySelector('input[name=q]').focus();
67 results_store.set(undefined);
73 if (pageinfo.tab === 'search') {
74 loaddata(pageinfo.params);
80 <SearchSection api_request_params={api_request_params} bStructuredSearch={bStructuredSearch} />
85 <ResultsList bind:current_result reverse_search={false} />
87 <div id="map-wrapper">
88 <Map {current_result} display_minimap={true} />
105 height: calc(100vh - 250pt);
113 @media (max-width: 768px) {