gisonjourney / leaflet-search

Search stuff in a Leaflet map

Home Page:http://labs.easyblog.it/maps/leaflet-search/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Licensed under the MIT license.

Copyright Stefano Cudini

Tested in Leaflet 0.7.7 and 1.1.1

Image

Where

Demo:
labs.easyblog.it/maps/leaflet-search

Source code:
Github NPM

Bug tracking:

Waffle.io

Websites that use Leaflet.Control.Search

Install

npm install --save leaflet-search

Events

Event Data Description
'search:locationfound' {latlng, title, layer} fired after moved and show markerLocation
'search:expanded' {} fired after control was expanded
'search:collapsed' {} fired after control was collapsed

Methods

Method Arguments Description
setLayer() L.LayerGroup() set layer search at runtime
showAlert() 'Text message' show alert message
searchText() 'Text searched' search text by external code

Examples

(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 ...
L.map('map', { searchControl: {layer: searchLayer} });

AMD module:

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

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

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

Build

Therefore the deployment require npm installed in your system.

npm install
grunt

About

Search stuff in a Leaflet map

http://labs.easyblog.it/maps/leaflet-search/

License:MIT License


Languages

Language:JavaScript 67.4%Language:Python 11.6%Language:CSS 11.1%Language:HTML 9.9%