X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/d363016e87dd121c1a0a2e01a9b057a97a6c4a5a..aabb32c8a1e90534f3ee61e428e668280587dfd9:/src/assets/js/base.js?ds=sidebyside diff --git a/src/assets/js/base.js b/src/assets/js/base.js index 02c228a..5754e3d 100644 --- a/src/assets/js/base.js +++ b/src/assets/js/base.js @@ -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(','); } @@ -46,6 +56,12 @@ function map_viewbox_as_string() { *********************************************************/ function fetch_from_api(endpoint_name, params, callback) { + + // `&a=&b=&c=1` => '&c=' + for(var k in params) { + if (typeof(params[k]) === 'undefined' || params[k] === '' || params[k] === null ) delete params[k]; + } + var api_url = get_config_value('Nominatim_API_Endpoint') + endpoint_name + '.php?' + $.param(params); if (endpoint_name !== 'status') { $('#api-request-link').attr('href', api_url); @@ -57,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.formatted); + $('#data-date').text(data.data_updated); }); }