<script>
+ import UrlSubmitForm from '../components/UrlSubmitForm.svelte';
import { zoomLevels } from '../lib/helpers.js';
import { map_store } from '../lib/stores.js';
}
function set_viewbox(map) {
- let set_viewbox = document.getElementById('use_viewbox');
- if (set_viewbox && set_viewbox.checked) {
+ let use_viewbox = document.getElementById('use_viewbox');
+ if (use_viewbox && use_viewbox.checked) {
sViewBox = map_viewbox_as_string(map);
} else {
sViewBox = '';
let link = document.getElementById('switch-to-reverse');
if (link) {
let center_lat_lng = map.wrapLatLng(map.getCenter());
- link.href = 'reverse.html?lat=' + center_lat_lng.lat.toFixed(5) + '&lon=' + center_lat_lng.lng.toFixed(5);
+ link.href = 'reverse.html?lat=' + center_lat_lng.lat.toFixed(5)
+ + '&lon=' + center_lat_lng.lng.toFixed(5);
}
}
map_store.subscribe(map => {
- if(!map) { return; }
+ if (!map) { return; }
map.on('move', function () {
set_viewbox(map);
- update_reverse_link(map)
+ update_reverse_link(map);
});
map.on('load', function () {
set_viewbox(map);
- update_reverse_link(map)
+ update_reverse_link(map);
+ });
+
+ map.on('click', function (e) {
+ if (reverse_search) {
+ document.querySelector('input[name=lat]').value = e.latlng.lat.toFixed(5);
+ document.querySelector('input[name=lon]').value = e.latlng.wrap().lng.toFixed(5);
+ document.querySelector('form').submit();
+ }
});
});
function reset_viewbox() {
let map = get(map_store);
- if (map) { set_viewbox(map) };
+ if (map) { set_viewbox(map); }
}
function set_bounded(e) {
document.querySelector('input[name=dedupe]').value = e.target.checked ? 1 : '';
}
- function set_api_param(e){
- document.querySelector('input[name=' + e.target.dataset['apiParam'] + ']').value = e.target.value;
+ function set_api_param(e) {
+ document.querySelector('input[name=' + e.target.dataset.apiParam + ']').value = e.target.value;
}
function handleSwitchCoords() {
{#if reverse_search}
<div class="top-bar">
- <form class="form-inline" role="search" accept-charset="UTF-8" action="">
+ <UrlSubmitForm>
<div class="form-group">
<input name="format" type="hidden" value="html">
<label for="reverse-lat">lat</label>
<a href="details.html" class="mr-2">search by id</a>
<a href="search.html">forward search</a>
</div>
- </form>
+ </UrlSubmitForm>
</div>
{:else}
</ul>
<div class="tab-content p-2">
<div class="tab-pane" class:active={!bStructuredSearch} id="simple" role="tabpanel">
- <form class="form-inline" role="search" accept-charset="UTF-8" action="">
+ <UrlSubmitForm>
<input id="q"
name="q"
type="text"
<input type="hidden" name="limit" value="{api_request_params.limit || ''}" />
<input type="hidden" name="polygon_threshold" value="{api_request_params.polygon_threshold || ''}" />
</div>
- </form>
+ </UrlSubmitForm>
</div>
<div class="tab-pane" class:active={bStructuredSearch} id="structured" role="tabpanel">
- <form class="form-inline" role="search" accept-charset="UTF-8" action="">
+ <UrlSubmitForm>
<input name="street" type="text" class="form-control form-control-sm mr-1"
placeholder="House number/Street"
value="{api_request_params.street || ''}" />
<input type="hidden" name="limit" value="{api_request_params.limit || ''}" />
<input type="hidden" name="polygon_threshold" value="{api_request_params.polygon_threshold || ''}" />
</div>
- </form>
+ </UrlSubmitForm>
</div>
<!-- Additional options -->
<a href="#advanced" class="btn btn-outline-secondary btn-sm" data-toggle="collapse" data-target="#searchAdvancedOptions" role="button" aria-expanded="false" aria-controls="collapseAdvancedOptions">
align-items: baseline
}
- form #q {
+ #q {
min-width: 500px;
}
@media (max-width: 850px) {
- form #q {
+ #q {
min-width: 400px;
}
}
label {
font-weight: normal;
+ margin-left: 0.4rem;
+ margin-right: 0.4rem;
}
#searchAdvancedOptionsContent {
padding: 4px 10px;
}
- form label {
- margin-left: 0.4rem;
- margin-right: 0.4rem;
- }
-
-
.search-type-link {
display: inline;
margin-right: 2em;
display: inline;
}
}
-</style>
\ No newline at end of file
+</style>