1.0.0 • Published 4 years ago

@foto-andreas/leaflet-control-textinput v1.0.0

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
4 years ago

Usage

Download latest release.

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: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.Control.textinput().addTo(map);

Customizing

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);

API

L.Control.Textinput

This is the textinput control. It works like any other Leaflet control, and is added to the map.

Constructor

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);

Options

OptionTypeDefaultDescription
collapsedBooleantrueCollapse control unless hovered/clicked
expandString"touch"How to expand a collapsed control: touch or click or hover
positionString"topright"Control position
placeholderString"URL..."Placeholder text for text input
textString""Initial query string for text input

Methods

MethodReturnsDescription
setText(<String> text)thisSets the text on the input