Leaflet.AnimatedSearchBox

A simple Leaflet plugin that provides a collapsible search box.

demo

Examples

Usage

<link href="src/AnimatedSearchBox.css" rel="stylesheet">
<script src="src/AnimatedSearchBox.js"></script>
var searchbox = L.control.searchbox({
    position: 'topright',
    expand: 'left'
}).addTo(map);

Options

Methods

// Expand the searchbox
searchbox.show()

// Collapse the searchbox
searchbox.hide()

// Toogle the searchbox
searchbox.toggle()

// Returns true if searchbox is collapsed
searchbox.isCollapsed()

// Returns current value of the text field of the searchbox
searchbox.getValue()

// Sets the value of the text field of the search box
searchbox.setValue(value)

// Adds an item to the autocomplete list
searchbox.addItem(item)

// Adds items to the autocomplete list
searchbox.addItems(items)

// Sets items of the autocomplete list
searchbox.setItems(items)

// Clears the autocomplete list
searchbox.clearItems()

// Clears the text field of the search box
searchbox.clearInput()

// Clears the text field and the autocomplete list of the search box
searchbox.clear()

// Adds a listener function (handler) to a particular DOM event (event)
// of the input field of the searchbox
searchbox.onInput(event, handler);

// Removes a previously added listener function (handler) of a particular DOM event (event)
// from the input field of the searchbox
searchbox.offInput(event, handler);

// Adds a listener function (handler) to a particular DOM event (event)
// of the button of the searchbox
searchbox.onButton(event, handler);

// Removes a previously added listener function (handler) of a particular DOM event (event)
// from the button of the searchbox
searchbox.offButton(event, handler);

// Adds a listener function (handler) to a particular DOM event (event)
// of the autocomplete list
searchbox.onAutocomplete(event, handler);

// Removes a previously added listener function (handler) of a particular DOM event (event)
// from the autocomplete list
searchbox.offAutocomplete(event, handler);

Planned features