From 8312e8f53977fc58f2419fac359543cc4fdabbf4 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Sun, 30 Oct 2016 17:45:45 +0100 Subject: [PATCH] UI: keep map position when switch to reverse. Easy switching of lat,lon to lon,lat --- lib/template/address-html.php | 1 + lib/template/search-html.php | 2 +- website/css/search.css | 6 ++++++ website/js/nominatim-ui.js | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/template/address-html.php b/lib/template/address-html.php index 4a9f6325..b4c7533e 100644 --- a/lib/template/address-html.php +++ b/lib/template/address-html.php @@ -14,6 +14,7 @@
+ <> max zoom diff --git a/lib/template/search-html.php b/lib/template/search-html.php index 02c338cd..14ebacc8 100644 --- a/lib/template/search-html.php +++ b/lib/template/search-html.php @@ -27,7 +27,7 @@
diff --git a/website/css/search.css b/website/css/search.css index d018ab94..eb0d06d7 100644 --- a/website/css/search.css +++ b/website/css/search.css @@ -26,6 +26,12 @@ form label { right: 0 } +#switch-coords { + font-size: 0.8em; + font-weight: bold; + cursor: pointer; +} + .sidebar { width: 25%; padding: 15px; diff --git a/website/js/nominatim-ui.js b/website/js/nominatim-ui.js index 7c19b17a..c5e91cf7 100644 --- a/website/js/nominatim-ui.js +++ b/website/js/nominatim-ui.js @@ -72,6 +72,15 @@ jQuery(document).on('ready', function(){ html_viewbox = "viewbox: " + map_viewbox_as_string(); $('#map-position-inner').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('
')); + + var reverse_params = { + lat: map.getCenter().lat.toFixed(5), + lon: map.getCenter().lng.toFixed(5), + zoom: map.getZoom(), + format: 'html' + } + $('#switch-to-reverse').attr('href', 'reverse.php?' + $.param(reverse_params)); + $('input#use_viewbox').trigger('change'); } @@ -202,6 +211,14 @@ jQuery(document).on('ready', function(){ $('form input[name=lon]').val( e.latlng.lng); $('form').submit(); }); + + $('#switch-coords').on('click', function(e){ + var lat = $('form input[name=lat]').val(); + var lon = $('form input[name=lon]').val(); + $('form input[name=lat]').val(lon); + $('form input[name=lon]').val(lat); + $('form').submit(); + }); } highlight_result(0, false); -- 2.45.1