]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/js/nominatim-ui.js
UI: keep map position when switch to reverse. Easy switching of lat,lon to lon,lat
[nominatim.git] / website / js / nominatim-ui.js
index 7c19b17a98a82cbfbbc9da2c85e79497d16b31dc..c5e91cf79d45574280899cd1d51be5425567b003 100644 (file)
@@ -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('<br/>'));
+
+        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);