Skip to content

Commit

Permalink
Reverse page: new optional parameter -layer-
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmail committed Jan 2, 2024
1 parent c8f2b84 commit 8258a52
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/components/SearchSectionReverse.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
export let lat = '';
export let lon = '';
export let zoom = '';
export let api_request_params = {};
function gotoCoordinates(newlat, newlon, newzoom) {
if (newlat === null || newlon === null) return;
Expand Down Expand Up @@ -36,6 +37,9 @@
}
}
function set_api_param(e) {
document.querySelector('input[name=' + e.target.dataset.apiParam + ']').value = e.target.value;
}
</script>

<UrlSubmitForm page="reverse">
Expand Down Expand Up @@ -81,11 +85,27 @@
{/each}
</select>
</div>
<input type="hidden"
name="layer" value="{api_request_params.layer || ''}" />
<div class="col-auto">
<button type="submit" class="btn btn-primary btn-sm mx-1">Search</button>
</div>
</UrlSubmitForm>

<!-- Additional options -->
<details id="searchAdvancedOptions" class="mt-2">
<summary><small>Advanced options</small></summary>
<ul>
<li>
<label for="option_layer">Layer</label>
<input id="option_layer" name="layer" placeholder="e.g. address,poi,railway,natural,manmade"
value="{api_request_params.layer || ''}"
data-api-param="layer" on:change={set_api_param}
class="form-control form-control-sm d-inline w-auto api-param-setting">
</li>
</ul>
</details>

<style>
label {
font-size: 0.9rem;
Expand All @@ -100,6 +120,24 @@
margin: 5px;
}
#searchAdvancedOptions ul {
list-style-type: none;
padding: 0;
font-size: 0.85rem;
}
#searchAdvancedOptions li {
display: inline-block;
padding: 4px 10px;
border-radius: 5px;
border: 1px dotted #ccc;
margin-right: 1em;
}
#searchAdvancedOptions label {
margin-right: 0.5em;
}
@media (max-width: 850px) {
#reverse-lon, #reverse-lat, #reverse-zoom {
width: 8em;
Expand Down
6 changes: 5 additions & 1 deletion src/pages/ReversePage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
zoom: (search_params.get('zoom') > 1
? Number(search_params.get('zoom'))
: Number(Nominatim_Config.Reverse_Default_Search_Zoom)),
layer: search_params.get('layer'),
format: 'jsonv2'
};
Expand Down Expand Up @@ -53,7 +54,10 @@
</script>

<Header>
<SearchSectionReverse {...api_request_params} />
<SearchSectionReverse lat={api_request_params.lat}
lon={api_request_params.lon}
zoom={api_request_params.zoom}
api_request_params={api_request_params} />
</Header>

<div id="content">
Expand Down

0 comments on commit 8258a52

Please sign in to comment.