leaflet-geosearch
leaflet-geosearch copied to clipboard
autoComplete: false not work (expected enter key)
Hello,
i don't want the autocomplete option. I don't spam the provider every 250ms.
So, my Question, if i set autoComplete: false, the search result if i press enter is not showing. If i press enter, it looks the map center to the first result. But i don't see the dropdown results if i press enter...
That's working as its (currently) intended. If you don't want to spam the server every 250ms, but do want to show suggestions, you'll need to increase the autoCompleteDelay duration.
In the onSubmit method the resultList is cleared but this is only available when autoComplete is enabled and throws an error when setting autoComplete option to false.
https://github.com/smeijer/leaflet-geosearch/blob/9197b372c28277ff81a28af2afa360fc33d16bc0/src/SearchControl.ts#L385
Suggested solutions:
Call the clearResults method instead of directly clearing the resultList
this.clearResults();
or check the autoComplete option first before calling the clear
const { autoComplete } = this.options;
if (autoComplete) {
this.resultList.clear();
}