Skip to content

Commit

Permalink
Merge pull request #218 from VandanaAwasthi/master
Browse files Browse the repository at this point in the history
Add configurable debounce timer for autocomplete to trigger search
  • Loading branch information
jonataswalker authored Sep 26, 2020
2 parents c248677 + b8fcb31 commit 3f5e2be
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ geocoder.on('addresschosen', function(evt){
* `key` : `''`; API Key if required;
* `autoComplete` : `false`; Search as you type;
* `autoCompleteMinLength`: `2`; The minimum number of characters to trigger search;
* `autoCompleteTimeout` : `200`; The mimimum number of ms to wait before triggering search if autoComplete is on and minimum number of characters is satisfied;
* `placeholder` : `'Search for an address'`; Placeholder for text input;
* `targetType` : `'glass-button'`; Can also be `'text-input'`;
* `featureStyle` : `ol.style.Style`; Feature style;
Expand Down
1 change: 1 addition & 0 deletions examples/custom-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
provider: provider,
autoComplete: true,
autoCompleteMinLength: 3,
autoCompleteTimeout: 200,
targetType: 'text-input',
lang: 'en',
keepOpen: false,
Expand Down
1 change: 1 addition & 0 deletions konstants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ export const DEFAULT_OPTIONS = {
preventDefault: false,
autoComplete: false,
autoCompleteMinLength: 2,
autoCompleteTimeout: 200,
debug: false,
};
2 changes: 1 addition & 1 deletion src/nominatim.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Nominatim {
if (value.length >= this.options.autoCompleteMinLength) {
this.query(value);
}
}, 200);
}, this.options.autoCompleteTimeout);
}
};
this.els.input.addEventListener('keypress', query, false);
Expand Down

0 comments on commit 3f5e2be

Please sign in to comment.