X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/68fd6dfad262e322f44815c835fdcf63b77ab639..6beafb16431a1cf87ad160ab50b07db31971d873:/dist/assets/js/nominatim-ui.js diff --git a/dist/assets/js/nominatim-ui.js b/dist/assets/js/nominatim-ui.js index d61aac5..05019aa 100644 --- a/dist/assets/js/nominatim-ui.js +++ b/dist/assets/js/nominatim-ui.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[i]; + var val = params[param_names[i]]; if (typeof (val) === 'undefined' || val === '' || val === null) { - delete param_names[i]; + delete params[param_names[i]]; } } @@ -355,7 +375,7 @@ function init_map_on_search_page(is_reverse_search, nominatim_results, request_l var container = L.DomUtil.create('div', 'my-custom-control'); $(container).text('show map bounds') - .addClass('leaflet-bar btn btn-sm btn-default') + .addClass('leaflet-bar btn btn-sm btn-outline-secondary') .on('click', function (e) { e.preventDefault(); e.stopPropagation(); @@ -633,7 +653,7 @@ jQuery(document).ready(function () { state: search_params.get('state'), country: search_params.get('country'), postalcode: search_params.get('postalcode'), - polygon_geojson: search_params.get('polygon_geojson') ? 1 : 0, + polygon_geojson: get_config_value('Search_AreaPolygons', false) ? 1 : 0, viewbox: search_params.get('viewbox'), exclude_place_ids: search_params.get('exclude_place_ids'), format: 'jsonv2' @@ -642,7 +662,7 @@ jQuery(document).ready(function () { context = { sQuery: api_request_params.q, sViewBox: search_params.get('viewbox'), - env: Nominatim_Config + env: {} }; if (api_request_params.street || api_request_params.city || api_request_params.county