The AfriGIS Address Search headless Library is aimed at creating accessible underlying logic and functionality to implement AfriGIS Search UI components without prescribing a specific visual style.
The AfriGIS Address Search headless Library is aimed at creating accessible underlying logic and functionality to implement AfriGIS Search UI components without prescribing a specific visual style.
* Clone the repo
* Run NPM Install
* Run Development Server
``bash`
npm run serve
``
const agSearch = new AfriGISAddressSearch({
...
});
Initialisation takes an options object as input. An explanation of the properties follows:
`
export interface IAfriGISAddressSearchOptions {
// API key for authentication.
// Required
apiKey: string;
// Callback handler for when the Suggestions change
// Required
onSuggestionsChange: (suggestions: IAfriGISAddressSearchSuggestion[]) => void;
// Callback handler for when the Selected Address payload changes
// Required
onSelectedAddressChange: (address: string) => void;
// Default is "https://afrigis.services"
baseUrl?: string;
// Minimum characters required before suggestions engine kick in. Default is 3 characters
minChars?: number;
// Debounce rate in milliseconds, default is 350ms
debounceMs?: number;
// Maximum amount of suggestions to return, a value between 1 and 20, default is 5
maxResults?: number;
// Array of strings to specify which types to include in suggestions, refer to https://developers.afrigis.co.za/oas3/autocomplete-api/api/v3/autocomplete
includeTypes?: string[]; // array of strings
// Array of strings to specify which types to exclude in suggestions, refer to https://developers.afrigis.co.za/oas3/autocomplete-api/api/v3/autocomplete
excludeTypes?: string[]; // array of strings
// Specifies which format to return the selected Address Payload in. Default is 'details'
addressComponentsFormat?: 'details' | 'delivery';
// JWT token for authentication
jwtToken?: string;
}
``
Resets the selected Address and the suggestions
Fires off the call to retrieve autocomplete suggestions
Fires off the call to retrieve address search suggestions (a backup to autocomplete)
Fires off the call to retrieve the Address Information for a specific address reference
Sets the API key (useful in a multitenant situation)
Sets the Address Components Format for selected Addresses
Sets the JWT token. Necessary for long-running frontends as the JWT token expires in 60 minutes.