Search stuff in a Leaflet map
JavaScript Python CSS HTML
Latest commit 82045e9 Nov 28, 2016 @stefanocudini update comments

Leaflet Control Search

npm version

A Leaflet control that search markers/features location by custom property.
Support ajax/jsonp autocompletion and JSON data filter/remapping.

Copyright 2016 Stefano Cudini

Tested in Leaflet 0.7.7,1.0




Source code:
Github NPM

Bug tracking:

Websites that use Leaflet.Control.Search


(require src/leaflet-search.css)

Adding the search control to the map:

var searchLayer = L.layerGroup().addTo(map);
//... adding data in searchLayer ...
map.addControl( new L.Control.Search({layer: searchLayer}) );
//searchLayer is a L.LayerGroup contains searched markers

Short way:

var searchLayer = L.geoJson().addTo(map);
//... adding data in searchLayer ...'map', { searchControl: {layer: searchLayer} });

AMD module:

require(["leaflet", "leafletSearch"],function(L, LeafletSearch) {

    //... initialize leaflet map and dataLayer ...

    map.addControl( new LeafletSearch({
        layer: dataLayer
    }) );


Therefore the deployment require npm installed in your system.

npm install