Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"eslint.enable": false,
"editor.formatOnSave": false,
"editor.autoIndent": "none",
"editor.codeActionsOnSave": {

}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ npm install --save leaflet-search
| propertyName | 'title' | property in marker.options(or feature.properties for vector layer) trough filter elements in layer, |
| formatData | null | callback for reformat all data from source to indexed data object |
| filterData | null | callback for filtering data from text searched, params: textSearch, allRecords |
| filtersearch | null | Optional comma-separated string to prepend to the search text |
| moveToLocation | null | callback run on location found, params: latlng, title, map |
| buildTip | null | function to return row tip html node(or html string), receive text tooltip in first param |
| container | '' | container id to insert Search Control |
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-search.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/leaflet-search.mobile.src.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Leaflet Control Search v3.0.10 - 2023-08-08
* Leaflet Control Search v4.0.0 - 2025-04-14
*
* Copyright 2023 Stefano Cudini
* Copyright 2025 Stefano Cudini
* [email protected]
* https://opengeo.tech/
*
Expand Down
4 changes: 2 additions & 2 deletions dist/leaflet-search.src.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Leaflet Control Search v3.0.10 - 2023-08-08
* Leaflet Control Search v4.0.0 - 2025-04-14
*
* Copyright 2023 Stefano Cudini
* Copyright 2025 Stefano Cudini
* [email protected]
* https://opengeo.tech/
*
Expand Down
12 changes: 8 additions & 4 deletions dist/leaflet-search.src.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Leaflet Control Search v3.0.10 - 2023-08-08
* Leaflet Control Search v4.0.0 - 2025-04-14
*
* Copyright 2023 Stefano Cudini
* Copyright 2025 Stefano Cudini
* [email protected]
* https://opengeo.tech/
*
Expand Down Expand Up @@ -80,6 +80,7 @@
propertyName: 'title', // property in marker.options(or feature.properties for vector layer) trough filter elements in layer,
formatData: null, // callback for reformat all data from source to indexed data object
filterData: null, // callback for filtering data from text searched, params: textSearch, allRecords
filtersearch: null, // Optional comma-separated string to prepend to the search text
moveToLocation: null, // callback run on location found, params: latlng, title, map
buildTip: null, // function to return row tip html node(or html string), receive text tooltip in first param
container: '', // container id to insert Search Control
Expand Down Expand Up @@ -748,8 +749,11 @@
this._retrieveData = this.options.jsonpParam ? this._recordsFromJsonp : this._recordsFromAjax
}

this._curReq = this._retrieveData.call(this, inputText, function (data) {
self._recordsCache = self._formatData(self, data)
filterText =
(this.options.filtersearch ? this.options.filtersearch.replace(/,+$/, "") + "," : "") + inputText;

this._curReq = this._retrieveData.call(this, filterText, function (data) {
self._recordsCache = self._formatData.call(self, data)

// TODO refact!
if (self.options.sourceData) { records = self._filterData(self._input.value, self._recordsCache) } else { records = self._recordsCache }
Expand Down
8 changes: 6 additions & 2 deletions src/leaflet-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
propertyName: 'title', // property in marker.options(or feature.properties for vector layer) trough filter elements in layer,
formatData: null, // callback for reformat all data from source to indexed data object
filterData: null, // callback for filtering data from text searched, params: textSearch, allRecords
filtersearch: null, // Optional comma-separated string to prepend to the search text
moveToLocation: null, // callback run on location found, params: latlng, title, map
buildTip: null, // function to return row tip html node(or html string), receive text tooltip in first param
container: '', // container id to insert Search Control
Expand Down Expand Up @@ -732,8 +733,11 @@
this._retrieveData = this.options.jsonpParam ? this._recordsFromJsonp : this._recordsFromAjax
}

this._curReq = this._retrieveData.call(this, inputText, function (data) {
self._recordsCache = self._formatData(self, data)
filterText =
(this.options.filtersearch ? this.options.filtersearch.replace(/,+$/, "") + "," : "") + inputText;

this._curReq = this._retrieveData.call(this, filterText, function (data) {
self._recordsCache = self._formatData.call(self, data)

// TODO refact!
if (self.options.sourceData) { records = self._filterData(self._input.value, self._recordsCache) } else { records = self._recordsCache }
Expand Down