Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { GeoSearchControl, OpenStreetMapProvider } from 'leaflet-geosearch';
const searchControl = new GeoSearchControl({
provider: new OpenStreetMapProvider(),
style: 'bar',
resetButton: '🔍', // Example of using a magnifying glass icon
});

map.addControl(searchControl);
Expand Down
4 changes: 3 additions & 1 deletion src/SearchControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
createElement,
addClassName,
removeClassName,
stopPropagation,

Check warning on line 11 in src/SearchControl.ts

View workflow job for this annotation

GitHub Actions / Eslint

'stopPropagation' is defined but never used
} from './domUtils';
import {
ENTER_KEY,
Expand All @@ -17,7 +17,7 @@
ARROW_DOWN_KEY,
ESCAPE_KEY,
} from './constants';
import AbstractProvider, { SearchResult } from './providers/provider';

Check warning on line 20 in src/SearchControl.ts

View workflow job for this annotation

GitHub Actions / Eslint

'AbstractProvider' is defined but never used
import { Provider } from './providers';

const defaultOptions: Omit<SearchControlProps, 'provider'> = {
Expand Down Expand Up @@ -56,6 +56,7 @@
autoClose: false,
keepResult: false,
updateMap: true,
resetButton: '×',
};

const UNINITIALIZED_ERR =
Expand Down Expand Up @@ -110,6 +111,7 @@
autoClose: boolean;
keepResult: boolean;
updateMap: boolean;
resetButton: string;
}

export type SearchControlOptions = Partial<SearchControlProps> & {
Expand Down Expand Up @@ -202,7 +204,7 @@
this.classNames.resetButton,
this.searchElement.form,
{
text: '×',
text: this.options.resetButton,
'aria-label': this.options.clearSearchLabel,
onClick: () => {
if (this.searchElement.input.value === '') {
Expand Down Expand Up @@ -282,7 +284,7 @@
);

this.container.appendChild(this.searchElement.form);
root!.appendChild(this.container);

Check warning on line 287 in src/SearchControl.ts

View workflow job for this annotation

GitHub Actions / Eslint

Forbidden non-null assertion
}

L.DomEvent.disableClickPropagation(this.searchElement.form);
Expand Down Expand Up @@ -373,7 +375,7 @@
const { provider } = this.options;

if (query.length) {
let results = await provider!.search({ query });

Check warning on line 378 in src/SearchControl.ts

View workflow job for this annotation

GitHub Actions / Eslint

Forbidden non-null assertion
results = results.slice(0, this.options.maxSuggestions);
this.resultList.render(results, this.options.resultFormat);
} else {
Expand All @@ -385,7 +387,7 @@
this.resultList.clear();
const { provider } = this.options;

const results = await provider!.search(query);

Check warning on line 390 in src/SearchControl.ts

View workflow job for this annotation

GitHub Actions / Eslint

Forbidden non-null assertion

if (results && results.length > 0) {
this.showResult(results[0], query);
Expand Down
Loading