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
-
Thank you for providing the excellent search functionality. I have a question that requires your assistance.
![Snipaste_2024-04-17_21-23-39](https://private-user-images.githubusercontent.com/6620570/323236751-375e0da3-cc58-4fac-a497-706addeb16df.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwODAzMTcsIm5iZiI6MTczOTA4MDAxNywicGF0aCI6Ii82NjIwNTcwLzMyMzIzNjc1MS0zNzVlMGRhMy1jYzU4LTRmYWMtYTQ5Ny03MDZhZGRlYjE2ZGYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDlUMDU0NjU3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTI0NWVmMGZmNDhmYTFmMWEyOWFhNGM3MmM1MTY3ZmVjN2U3YjZjMGU1MjQ2MGZhNTY2ODhjOTY3NmU2NWY2NyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.C5BLK7oraI16If7AkmNax1cpAdlSNr349lmSxC9HrTk)
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