X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/1df5c38175a3d15f8e595f49506b4dfb46e73d29..4cef4fd8107653656e83662f71c4cdaeb94708ab:/src/assets/js/base.js?ds=inline
diff --git a/src/assets/js/base.js b/src/assets/js/base.js
index 98f7ee8..4ff6b23 100644
--- a/src/assets/js/base.js
+++ b/src/assets/js/base.js
@@ -3,13 +3,33 @@
var map;
var last_click_latlng;
+// *********************************************************
+// DEFAULTS
+// *********************************************************
+
+var Nominatim_Config_Defaults = {
+ Nominatim_API_Endpoint: 'http://localhost/nominatim/',
+ Images_Base_Url: '/mapicons/',
+ Search_AreaPolygons: 1,
+ Reverse_Default_Search_Zoom: 18,
+ Map_Default_Lat: 20.0,
+ Map_Default_Lon: 0.0,
+ Map_Default_Zoom: 2,
+ Map_Tile_URL: 'https://{s}.tile.osm.org/{z}/{x}/{y}.png',
+ Map_Tile_Attribution: 'OpenStreetMap contributors'
+};
// *********************************************************
// HELPERS
// *********************************************************
+
function get_config_value(str, default_val) {
- return (typeof Nominatim_Config[str] !== 'undefined' ? Nominatim_Config[str] : default_val);
+ var value = ((typeof Nominatim_Config !== 'undefined')
+ && (typeof Nominatim_Config[str] !== 'undefined'))
+ ? Nominatim_Config[str]
+ : Nominatim_Config_Defaults[str];
+ return (typeof value !== 'undefined' ? value : default_val);
}
function parse_and_normalize_geojson_string(part) {
@@ -61,13 +81,13 @@ function map_viewbox_as_string() {
// *********************************************************
function fetch_from_api(endpoint_name, params, callback) {
+ //
// `&a=&b=&c=1` => '&c=1'
-
var param_names = Object.keys(params);
for (var i = 0; i < param_names.length; i += 1) {
- var val = param_names[keys[i]];
+ var val = params[param_names[i]];
if (typeof (val) === 'undefined' || val === '' || val === null) {
- delete param_names[keys[i]];
+ delete params[param_names[i]];
}
}
@@ -111,14 +131,17 @@ function hide_error() {
}
-$(document).ajaxError(function (event, jqXHR, ajaxSettings/* , thrownError */) {
- // console.log(thrownError);
- // console.log(ajaxSettings);
- var url = ajaxSettings.url;
- show_error('Error fetching results from ' + url + '');
-});
-
-
jQuery(document).ready(function () {
hide_error();
+
+ $(document).ajaxStart(function () {
+ $('#loading').fadeIn('fast');
+ }).ajaxComplete(function () {
+ $('#loading').fadeOut('fast');
+ }).ajaxError(function (event, jqXHR, ajaxSettings/* , thrownError */) {
+ // console.log(thrownError);
+ // console.log(ajaxSettings);
+ var url = ajaxSettings.url;
+ show_error('Error fetching results from ' + url + '');
+ });
});