Giter Club home page Giter Club logo

leaflet.animatedsearchbox's Introduction

Leaflet.AnimatedSearchBox

A simple Leaflet plugin that provides a collapsible search box.

demo

Usage

<link href="src/AnimatedSearchBox.css" rel="stylesheet">
<script src="src/AnimatedSearchBox.js"></script>
  • Add the search icon image file to img/search_icon.png

  • Create a new L.Control.Searchbox and add it to the map:

var searchbox = L.control.searchbox({
    position: 'topright',
    expand: 'left'
}).addTo(map);

Options

  • position: Sets the position of the searchbox (Default: 'topright').
  • expand: Sets the direction in which the search box expands. (Default: 'left').
  • collapsed: Sets the initial state of the searchbox (Default: false).
  • id: Sets the id of the container of the searchbox.
  • class: Adds custom classes to the container of the searchbox.
  • width: Sets the width of the input field of the searchbox. (Example: '450px')
  • iconPath: Sets the path for the search icon (Default: 'img/search_icon.png').
  • autocompleteFeatures: Activates the given features (Default: []).
    Possible features:
    • 'setValueOnClick': Set the value of the searchbox to the value of the clicked autocomplete list item.
    • 'arrowKeyNavigation': Coming soon
    • 'setValueOnHover': Coming soon
    • 'setValueOnEnter': Coming soon

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

  • Add option to use <datalist> for autocomplete.
  • Support for npm etc.

leaflet.animatedsearchbox's People

Contributors

luka1199 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.