Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add postalCode param and handle null setters #189

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SearchAPI {
expandUnits,
mailable,
lang,
postalCode,
} = params;

// near can be provided as a string or Location object
Expand All @@ -46,6 +47,7 @@ class SearchAPI {
expandUnits,
mailable,
lang,
postalCode,
},
requestId,
});
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ export interface RadarAutocompleteParams {
expandUnits?: boolean;
mailable?: boolean;
lang?: string;
postalCode?: string;
}

export interface RadarAutocompleteResponse extends RadarResponse {
Expand Down
22 changes: 21 additions & 1 deletion src/ui/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class AutocompleteUI {
}

public async fetchResults(query: string) {
const { limit, layers, countryCode, expandUnits, mailable, onRequest } = this.config;
const { limit, layers, countryCode, expandUnits, mailable, lang, postalCode, onRequest } = this.config;

const params: RadarAutocompleteParams = {
query,
Expand All @@ -256,6 +256,8 @@ class AutocompleteUI {
countryCode,
expandUnits,
mailable,
lang,
postalCode,
}

if (this.near) {
Expand Down Expand Up @@ -530,6 +532,24 @@ class AutocompleteUI {
return this;
}

public setLang(lang: string | undefined | null) {
if (lang === undefined || lang === null) {
this.config.lang = undefined;
} else if (typeof lang === 'string') {
this.config.lang = lang;
}
return this;
}

public setPostalCode(postalCode: string | undefined | null) {
if (postalCode === undefined || postalCode === null) {
this.config.postalCode = undefined;
} else if (typeof postalCode === 'string') {
this.config.postalCode = postalCode;
}
return this;
}

public setShowMarkers(showMarkers: boolean) {
this.config.showMarkers = showMarkers;
if (showMarkers) {
Expand Down
Loading