How to hide 'not matched item' in the result list. #28
iplaywind
announced in
Announcements
Replies: 2 comments
-
Take a look at this library because it's the same thing - autocomplete. There are detailed examples of how to search in json files. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The code below should help: return new Promise((resolve) => {
fetch(api)
.then((response) => response.json())
.then((data) => {
const results = data.features.filter((element) => {
return element.properties.display_name
.toLowerCase()
.includes(currentValue);
});
resolve(results);
})
.catch((error) => {
console.error(error);
}); these are the basics of searching in a file :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Thank you for providing the excellent search functionality. I have a question that requires your assistance.

Please visit the webpage http://route.capas.oome.net/sharecode/Leaflet.Autocomplete-master/docs/index.html. I have used the code from this repository and run the docs/index.html file, with only modifications script.js file onlines 8-14 of the , changing the data source from api to the built-in search.json file.
When I search for "gmina," all 10 results are listed in the list, with 3 of them not matched "gmina".
Since my own geojson file contains thousands of data entries, I do not wish to display all the items. Instead, I would like to display only the entries that match the search keyword, as shown in the image.
How should I modify the JavaScript code ?
Beta Was this translation helpful? Give feedback.
All reactions