Skip to content

Commit 79c2145

Browse files
committed
control: set initial query via options
1 parent 02abfad commit 79c2145

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ L.Control.geocoder(options);
114114
| `showResultIcons` | Boolean | `false` | Show icons for geocoding results (if available); supported by Nominatim |
115115
| `suggestMinLength` | Number | `3` | Minimum number characters before suggest functionality is used (if available from geocoder) |
116116
| `suggestTimeout` | Number | `250` | Number of milliseconds after typing stopped before suggest functionality is used (if available from geocoder) |
117+
| `query` | String | `""` | Initial query string for text input |
117118
| `queryMinLength` | Number | `1` | Minimum number of characters in search text before performing a query |
118119

119120
### Methods

demo/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
}
4646

4747
var control = L.Control.geocoder({
48+
query: 'Moon',
49+
placeholder: 'Search here...',
4850
geocoder: geocoder
4951
}).addTo(map);
5052
var marker;

src/control.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export var Geocoder = L.Control.extend({
5252

5353
input = this._input = L.DomUtil.create('input', '', form);
5454
input.type = 'text';
55+
input.value = this.options.query || '';
5556
input.placeholder = this.options.placeholder;
5657
L.DomEvent.disableClickPropagation(input);
5758

0 commit comments

Comments
 (0)