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 SearchBar from '../components/SearchBar.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: get_config_value('Search_AreaPolygons', false) ? 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 document.querySelector('input[name=q]').focus();
53 results_store.set(undefined);
59 if (pageinfo.tab === 'search') {
60 loaddata(pageinfo.params);
65 <SearchBar api_request_params={api_request_params} bStructuredSearch={bStructuredSearch} />
69 <ResultsList bind:current_result reverse_search={false} />
71 <div id="map-wrapper">
72 <Map {current_result} display_minimap={true} />
82 display: inline-block;
89 height: calc(100vh - 250pt);
92 display: inline-block;
96 @media (max-width: 768px) {