]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/assets/js/searchpage.js
Merge pull request #40 from mtmail/navigation-to-details-index-page
[nominatim-ui.git] / src / assets / js / searchpage.js
index be9c20a3e48d30f7dfa60ba57dda72eacf155091..95d842d5d176f3fd3a29c84e7a25559ca38b39b2 100755 (executable)
@@ -339,6 +339,7 @@ function search_page_load() {
           aPlace = null;
         }
 
           aPlace = null;
         }
 
+        context.bSearchRan = true;
         context.aPlace = aPlace;
 
         render_template($('main'), 'reversepage-template', context);
         context.aPlace = aPlace;
 
         render_template($('main'), 'reversepage-template', context);
@@ -406,21 +407,23 @@ function search_page_load() {
 
       fetch_from_api('search', api_request_params, function (aResults) {
 
 
       fetch_from_api('search', api_request_params, function (aResults) {
 
+        context.bSearchRan = true;
         context.aSearchResults = aResults;
 
         context.aSearchResults = aResults;
 
-        if (aResults.length >= 10) {
-          var aExcludePlaceIds = [];
-          if (search_params.has('exclude_place_ids')) {
-            aExcludePlaceIds.search_params.get('exclude_place_ids').split(',');
-          }
-          for (var i = 0; i < aResults.length; i += 1) {
-            aExcludePlaceIds.push(aResults[i].place_id);
-          }
-
-          var parsed_url = new URLSearchParams(window.location.search);
-          parsed_url.set('exclude_place_ids', aExcludePlaceIds.join(','));
-          context.sMoreURL = '?' + parsed_url.toString();
+        // lonvia wrote: https://github.com/osm-search/nominatim-ui/issues/24
+        // I would suggest to remove the guessing and always show the link. Nominatim only returns
+        // one or two results when it believes the result to be a good enough match.
+        // if (aResults.length >= 10) {
+        var aExcludePlaceIds = [];
+        if (search_params.has('exclude_place_ids')) {
+          aExcludePlaceIds = search_params.get('exclude_place_ids').split(',');
+        }
+        for (var i = 0; i < aResults.length; i += 1) {
+          aExcludePlaceIds.push(aResults[i].place_id);
         }
         }
+        var parsed_url = new URLSearchParams(window.location.search);
+        parsed_url.set('exclude_place_ids', aExcludePlaceIds.join(','));
+        context.sMoreURL = '?' + parsed_url.toString();
 
         render_template($('main'), 'searchpage-template', context);
         update_html_title('Result for ' + api_request_params.q);
 
         render_template($('main'), 'searchpage-template', context);
         update_html_title('Result for ' + api_request_params.q);