Add the control to a map instance:
var map = L.map('map').setView([0, 0], 2);
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.Control.textinput().addTo(map);
By default, when a textinput is done, the control's textinput
event is emitted.
For example:
var textinput = L.Control.textinput({
})
.on('textinput', function(e) {
console.log(e.text);
})
.addTo(map);
This is the textinput control. It works like any other Leaflet control, and is added to the map.
This plugin supports the standard JavaScript constructor (to be invoked using new
) as well as the class factory methods known from Leaflet:
new L.Control.Textinput(options);
// or
L.Control.textinput(options);
Option | Type | Default | Description |
---|---|---|---|
collapsed |
Boolean | true |
Collapse control unless hovered/clicked |
expand |
String | "touch" |
How to expand a collapsed control: touch or click or hover |
position |
String | "topright" |
Control position |
placeholder |
String | "URL..." |
Placeholder text for text input |
text |
String | "" |
Initial query string for text input |
Method | Returns | Description |
---|---|---|
setText(<String> text) |
this |
Sets the text on the input |