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 layer: search_params.get('layer'),
32 limit: search_params.get('limit'),
33 polygon_threshold: search_params.get('polygon_threshold'),
34 exclude_place_ids: search_params.get('exclude_place_ids'),
38 let anyStructuredFieldsSet = (api_request_params.street
39 || api_request_params.city
40 || api_request_params.county
41 || api_request_params.state
42 || api_request_params.country
43 || api_request_params.postalcode);
45 if (api_request_params.q || anyStructuredFieldsSet) {
46 fetch_from_api('search', api_request_params, function (data) {
47 results_store.set(data);
49 if (anyStructuredFieldsSet) {
50 update_html_title('Result for ' + [
51 api_request_params.street,
52 api_request_params.city,
53 api_request_params.county,
54 api_request_params.state,
55 api_request_params.country,
56 api_request_params.postalcode
57 ].filter((text) => text && text.length > 1).join(', '));
59 document.querySelector(".nav-tabs a[href='#structured']").click();
60 document.querySelector('input[name=street]').focus();
62 update_html_title('Result for ' + api_request_params.q);
64 document.querySelector('input[name=q]').focus();
68 results_store.set(undefined);
74 if (pageinfo.tab === 'search') {
75 loaddata(pageinfo.params);
81 <SearchSection api_request_params={api_request_params} bStructuredSearch={bStructuredSearch} />
86 <ResultsList bind:current_result reverse_search={false} />
88 <div id="map-wrapper">
89 <Map {current_result} display_minimap={true} />
106 height: calc(100vh - 250pt);
114 @media (max-width: 768px) {