2 import { onMount, onDestroy } from 'svelte';
4 import { page, results_store, current_result_store, current_request_latlon } from '../lib/stores.js';
5 import { get_config_value } from '../lib/config_reader.js'
6 import { fetch_from_api, update_html_title } from '../lib/api_utils.js';
8 import SearchBar from '../components/SearchBar.svelte';
9 import ResultsList from '../components/ResultsList.svelte';
10 import Map from '../components/Map.svelte';
12 export let reverse_search = false;
14 let api_request_params;
15 let bStructuredSearch;
18 let search_params = new URLSearchParams(window.location.search);
23 api_request_params = {
24 lat: search_params.get('lat'),
25 lon: search_params.get('lon'),
26 zoom: (search_params.get('zoom') > 1
27 ? Number(search_params.get('zoom'))
28 : Number(get_config_value('Reverse_Default_Search_Zoom'))),
32 if (api_request_params.lat || api_request_params.lat) {
34 fetch_from_api('reverse', api_request_params, function(data){
35 if (data && !data.error){
36 current_request_latlon.set([api_request_params.lat, api_request_params.lon]);
37 results_store.set([data]);
39 results_store.set([]);
42 update_html_title('Reverse result for '
43 + api_request_params.lat
45 + api_request_params.lon);
46 document.querySelector('input[name=lat]').focus();
50 api_request_params = {
51 q: search_params.get('q'),
52 street: search_params.get('street'),
53 city: search_params.get('city'),
54 county: search_params.get('county'),
55 state: search_params.get('state'),
56 country: search_params.get('country'),
57 postalcode: search_params.get('postalcode'),
58 polygon_geojson: get_config_value('Search_AreaPolygons', false) ? 1 : 0,
59 viewbox: search_params.get('viewbox'),
60 bounded: search_params.get('bounded'),
61 dedupe: search_params.get('dedupe'),
62 'accept-language': search_params.get('accept-language'),
63 countrycodes: search_params.get('countrycodes'),
64 limit: search_params.get('limit'),
65 polygon_threshold: search_params.get('polygon_threshold'),
66 exclude_place_ids: search_params.get('exclude_place_ids'),
70 let bStructuredSearch = (api_request_params.street ||
71 api_request_params.city ||
72 api_request_params.county ||
73 api_request_params.state ||
74 api_request_params.country ||
75 api_request_params.postalcode);
77 if (api_request_params.q || bStructuredSearch) {
78 fetch_from_api('search', api_request_params, function(data){
79 results_store.set(data);
81 update_html_title('Result for ' + api_request_params.q);
83 document.querySelector('input[name=q]').focus();
89 let page_subscription;
90 onMount(() => { page_subscription = page.subscribe(loaddata); });
91 onDestroy(() => { page_subscription(); });
94 <SearchBar reverse_search={reverse_search} api_request_params={api_request_params} bStructuredSearch={bStructuredSearch} />
98 <ResultsList reverse_search={reverse_search} />
100 <div id="map-wrapper">
101 <Map display_minimap={true} />
111 display: inline-block;
118 height: calc(100vh - 250pt);
121 display: inline-block;
125 @media (max-width: 768px) {