Skip to content

Commit

Permalink
add postal code param
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspk06 committed Nov 11, 2024
1 parent 18993f6 commit 6a8fba5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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

0 comments on commit 6a8fba5

Please sign in to comment.