<commit_before># Leaflet Tag Filter Button
Adds tag filter control for marker to LeafLet. 

Required [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton)

Check out the [demo](https://leaflet-tag-filter-button.herokuapp.com)

Usage
-----

Simple usage :

If your markers contains tags option the plugin filters them by selected tags when popup is closed
For example:

```

var map = L.map('map');

var fastMarker = L.marker([50.5, 30.5], { tags: ['fast'] }).addTo(map); 
var slowMarker = L.marker([50.5, 30.5], { tags: ['slow'] }).addTo(map);
var bothMarker = L.marker([50.5, 30.5], { tags: ['fast', 'slow'] }).addTo(map);

L.tagFilterButton({
	data: ['fast', 'slow']
}).addTo( map );

```


Set data from external url/ajax :

*note: this option not implemented yet!*

```

var map = L.map('map');
L.tagFilterButton({
	ajaxData: function(callback) {
		$.get('https://leaflet-tag-filter-button.herokuapp.com/data', function(data)) {
			callback(data);
		}
	}
}).addTo( map );


```

Selection complete callback

```

var map = L.map('map');
L.tagFilterButton({
	data: function(callback) {
		$.get('https://leaflet-tag-filter-button.herokuapp.com/data', function(data)) {
			callback(data);
		}
	},
	onSelectionComplete: function(tags) {
		console.log('selected tags are', tags);
	}
}).addTo( map );


```


Authors
-------

* <NAME><commit_msg>readme update<commit_after># Leaflet Tag Filter Button
Adds tag filter control for marker to LeafLet. 

Required [Leaflet.EasyButton](https://github.com/CliffCloud/Leaflet.EasyButton)

Check out the [demo](https://leaflet-tag-filter-button.herokuapp.com)

Usage
-----

Simple usage :

If your markers contains tags option the plugin filters them by selected tags when popup is closed
For example:

```

var map = L.map('map');

var fastMarker = L.marker([50.5, 30.5], { tags: ['fast'] }).addTo(map); 
var slowMarker = L.marker([50.5, 30.5], { tags: ['slow'] }).addTo(map);
var bothMarker = L.marker([50.5, 30.5], { tags: ['fast', 'slow'] }).addTo(map);

L.tagFilterButton({
	data: ['fast', 'slow']
}).addTo( map );

```


Set data from external url/ajax :

*note: this option not implemented yet!*

```

var map = L.map('map');
L.tagFilterButton({
	ajaxData: function(callback) {
		$.get('https://leaflet-tag-filter-button.herokuapp.com/data', function(data)) {
			callback(data);
		}
	}
}).addTo( map );


```

Selection complete callback

```

var map = L.map('map');
L.tagFilterButton({
	data: function(callback) {
		$.get('https://leaflet-tag-filter-button.herokuapp.com/data', function(data)) {
			callback(data);
		}
	},
	onSelectionComplete: function(tags) {
		console.log('selected tags are', tags);
	}
}).addTo( map );


```


----------


API Docs
------

### Options

 - **icon**
> Buton icon default is fa-filter. You can use html syntax for the icon for example `<img src="/filter.png">`

 - **onSelectionComplete**
 > The callback function for selected tags. It fires when popup is closed and sends selected tags to the callback function as a parameter.
 
 - **data**
 > The data to be used for tags popup, it can be array or function

 - **clearText**
 > The text of the clear button. Default is "clear".

### Methods

 - **update**
> Update markers with last selected tags.
 
 - **hasFiltered**
 > returns true if any tag(s) selected otherwise false

 - **registerCustomSource**
 > Register @source object for filtering markers by tags. If you wanto to use this function you must implement @hide function  
 > - **@param source** reference of the new marker source. It must have name and source item

 - **enablePruneCluster**
 > Enable prune-cluster layer source. If you call this function the plugin search on prune-cluster instance for filtering. 
 > - **@param pruneClusterInstance** reference of the prune-cluster instance

----------

Change Log
-----

**v0.0.2 (30.06.2016)**

 - Added multi layer source support. 
 > You can add a new marker container layer source to plugin and the plugin searching on added source.
 
 - Added [PruneCluster](https://github.com/SINTEF-9012/PruneCluster) support.
 > Added [PruneCluster](https://github.com/SINTEF-9012/PruneCluster)  layer source to the plugin as default. You can enable it by enablePruneCluster function.

Authors
-------

* <NAME>
{'fraction_non_alphanumeric': 0.1621748300913991, 'fraction_numerical': 0.01288961799859386, 'mean_word_length': 3.828054298642534, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 18, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2663920', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1349, 'n_words': 426}