2 import { page, results_store } from '../lib/stores.js';
3 import { get_config_value } from '../lib/config_reader.js';
4 import { fetch_from_api, update_html_title } from '../lib/api_utils.js';
6 import Header from '../components/Header.svelte';
7 import SearchSection from '../components/SearchSection.svelte';
8 import ResultsList from '../components/ResultsList.svelte';
9 import Map from '../components/Map.svelte';
11 let api_request_params;
12 let bStructuredSearch;
15 function loaddata(search_params) {
18 api_request_params = {
19 q: search_params.get('q'),
20 street: search_params.get('street'),
21 city: search_params.get('city'),
22 county: search_params.get('county'),
23 state: search_params.get('state'),
24 country: search_params.get('country'),
25 postalcode: search_params.get('postalcode'),
26 polygon_geojson: get_config_value('Search_AreaPolygons', false) ? 1 : 0,
27 viewbox: search_params.get('viewbox'),
28 bounded: search_params.get('bounded'),
29 dedupe: search_params.get('dedupe'),
30 'accept-language': search_params.get('accept-language'),
31 countrycodes: search_params.get('countrycodes'),
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 update_html_title('Result for ' + api_request_params.q);
51 document.querySelector('input[name=q]').focus();
54 results_store.set(undefined);
60 if (pageinfo.tab === 'search') {
61 loaddata(pageinfo.params);
67 <SearchSection api_request_params={api_request_params} bStructuredSearch={bStructuredSearch} />
72 <ResultsList bind:current_result reverse_search={false} />
74 <div id="map-wrapper">
75 <Map {current_result} display_minimap={true} />
92 height: calc(100vh - 250pt);
100 @media (max-width: 768px) {