From c3b95d395e57cb5b1cf09061733bbb143d170bfb Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Wed, 16 Oct 2024 15:13:33 -0400 Subject: [PATCH] Update params and types for geocoding and search API (#184) --- README.md | 14 +++++++------- package-lock.json | 2 +- package.json | 2 +- src/api/geocoding.ts | 3 ++- src/api/search.ts | 2 ++ src/types.ts | 35 +++++++++++++++++++++++------------ src/version.ts | 2 +- 7 files changed, 37 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 2c177518..72d40367 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ }); Add the following script in your `html` file ```html - + ``` Then initialize the Radar SDK @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then ```html - - + + @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis ```html - - + + @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper ```html - - + + diff --git a/package-lock.json b/package-lock.json index d34767ed..8af4e0e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.4.3", + "version": "4.4.4", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index d1d08611..e86afbef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radar-sdk-js", - "version": "4.4.3", + "version": "4.4.4", "description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.", "homepage": "https://radar.com", "type": "module", diff --git a/src/api/geocoding.ts b/src/api/geocoding.ts index f2af72fb..2bf5f526 100644 --- a/src/api/geocoding.ts +++ b/src/api/geocoding.ts @@ -13,7 +13,7 @@ class Geocoding { static async forwardGeocode(params: RadarForwardGeocodeParams): Promise { const options = Config.get(); - const { query, layers, country } = params; + const { query, layers, country, lang } = params; const response: any = await Http.request({ method: 'GET', @@ -22,6 +22,7 @@ class Geocoding { query, layers, country, + lang, }, }); diff --git a/src/api/search.ts b/src/api/search.ts index f404481d..2bc81650 100644 --- a/src/api/search.ts +++ b/src/api/search.ts @@ -23,6 +23,7 @@ class SearchAPI { countryCode, expandUnits, mailable, + lang, } = params; // near can be provided as a string or Location object @@ -44,6 +45,7 @@ class SearchAPI { countryCode, expandUnits, mailable, + lang, }, requestId, }); diff --git a/src/types.ts b/src/types.ts index f1698cf0..2dd2c1e5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -270,6 +270,7 @@ export type RadarGeocodeLayer = | 'address' | 'postalCode' | 'locality' + | 'neighborhood' | 'county' | 'state' | 'country' @@ -302,10 +303,24 @@ export interface RadarAddress { street?: string; } +export interface RadarTimeZone { + id: string; + name: string; + code: string; + currentTime: string; + utcOffset: number; + dstOffset: number; +} + export interface RadarAutocompleteAddress extends RadarAddress { unit?: string; } +export interface RadarGeocodeAddress extends RadarAddress { + unit?: string; + timeZone?: RadarTimeZone; +} + export type RadarValidationRecordType = 'S' | 'R' | 'P' | 'M' | 'H' | 'G' | 'F' | undefined; export type RadarValidationPropertyType = 'commercial' | 'residential' | undefined; @@ -325,6 +340,7 @@ export interface RadarForwardGeocodeParams { query: string; layers?: RadarGeocodeLayer[]; country?: string; + lang?: string; } export interface RadarReverseGeocodeParams { @@ -333,13 +349,13 @@ export interface RadarReverseGeocodeParams { layers?: RadarGeocodeLayer[]; } -export interface RadarGeocodeResponse extends RadarResponse { - addresses: RadarAddress[]; +export interface RadarGeocodeResponse extends RadarResponse { + addresses: RadarGeocodeAddress[]; } export interface RadarIPGeocodeResponse extends RadarResponse { ip: string; - address?: RadarAddress; + address?: RadarGeocodeAddress; proxy?: boolean; } @@ -352,6 +368,7 @@ export interface RadarAutocompleteParams { /** @deprecated this is always true, regardless of the value passed here */ expandUnits?: boolean; mailable?: boolean; + lang?: string; } export interface RadarAutocompleteResponse extends RadarResponse { @@ -531,17 +548,12 @@ export interface RadarPolygonOptions { 'border-opacity'?: number; }, } -export interface RadarAutocompleteUIOptions { +export interface RadarAutocompleteUIOptions extends Omit { container: string | HTMLElement; - near?: string | Location; // bias for location results debounceMS?: number, // Debounce time in milliseconds - threshold?: number, // DEPRECATED(use minCharacters instead) + /** @deprecated use minCharacters instead */ + threshold?: number, minCharacters?: number, // Minimum number of characters to trigger autocomplete - limit?: number, // Maximum number of autocomplete results - layers?: RadarGeocodeLayer[]; - countryCode?: string; - expandUnits?: boolean; - mailable?: boolean; placeholder?: string, // Placeholder text for the input field onSelection?: (selection: any) => void, onRequest?: (params: RadarAutocompleteParams) => void, @@ -557,7 +569,6 @@ export interface RadarAutocompleteUIOptions { } export interface RadarAutocompleteConfig extends RadarAutocompleteUIOptions { - container: string | HTMLElement; debounceMS: number, // Debounce time in milliseconds threshold: number, // DEPRECATED(use minCharacters instead) minCharacters: number, // Minimum number of characters to trigger autocomplete diff --git a/src/version.ts b/src/version.ts index 9ca55d2c..6b04937f 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '4.4.3'; +export default '4.4.4';