]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/assets/js/base.js
leaflet 1.3 => 1.6
[nominatim-ui.git] / src / assets / js / base.js
index 9e8f86e7ebbe9ac32ff013557af6ea0e5e9fcedb..5754e3dcd916340a9b871c838d7e61eb52b58d1f 100644 (file)
@@ -31,12 +31,22 @@ function map_link_to_osm(){
 }
 
 function map_viewbox_as_string() {
-    // since .toBBoxString() doesn't round numbers
+    var bounds = map.getBounds();
+    var west = bounds.getWest();
+    var east = bounds.getEast();
+
+    if ((east - west) >= 360) { // covers more than whole planet
+        west = map.getCenter().lng-179.999;
+        east = map.getCenter().lng+179.999;
+    }
+    east = L.latLng(77, east).wrap().lng;
+    west = L.latLng(77, west).wrap().lng;
+
     return [
-        map.getBounds().getSouthWest().lng.toFixed(5), // left
-        map.getBounds().getNorthEast().lat.toFixed(5), // top
-        map.getBounds().getNorthEast().lng.toFixed(5), // right
-        map.getBounds().getSouthWest().lat.toFixed(5)  // bottom
+        west.toFixed(5), // left
+        bounds.getNorth().toFixed(5), // top
+        east.toFixed(5), // right
+        bounds.getSouth().toFixed(5) // bottom
     ].join(',');
 }
 
@@ -63,7 +73,7 @@ function fetch_from_api(endpoint_name, params, callback) {
 
 function update_data_date() {
     fetch_from_api('status', {format: 'json'}, function(data){
-        $('#data-date').text(data.data_last_updated);
+        $('#data-date').text(data.data_updated);
     });
 }