mobility-toolbox-js
Version:
Toolbox for JavaScript applications in the domains of mobility and logistics.
54 lines (53 loc) • 2.38 kB
TypeScript
import { StopsAPI } from '../../api';
import type { StopsAPIOptions } from '../../api/StopsAPI';
import type { StopsParameters, StopsResponse } from '../../types';
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType[number];
export type StopFinderControlCommonOptions = {
apiParams: StopsParameters;
element: HTMLElement;
onSuggestionClick?: (suggestion: ArrayElement<NonNullable<StopsResponse['features']>>, evt: MouseEvent) => void;
placeholder?: string;
} & StopsAPIOptions;
/**
* A class representing a stop finder control to display on map.
* This class only draw the html elements.
* The geographic logic must be implemented by subclasses.
*
* @private
*/
declare class StopFinderControlCommon {
abortController?: AbortController;
api: StopsAPI;
apiParams: StopsParameters;
clearElt?: HTMLDivElement;
inputElt?: HTMLInputElement;
options?: StopFinderControlCommonOptions;
placeholder: string;
suggestionsElt?: HTMLElement;
/**
* Constructor.
*
* @param {Object} options Options
* @param {HTMLElement} options.element HTML element where to attach input and suggestions.
* @param {string} options.apiKey Access key for [geOps services](https://developer.geops.io/). See StopsAPI.
* @param {string} [options.url='https://api.geops.io/stops/v1/'] Stops service url. See StopsAPI.
* @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
*/
constructor(options: StopFinderControlCommonOptions);
/**
* Clear the search field and close the control.
*/
clear(): void;
createElement({ element }: StopFinderControlCommonOptions): void;
render(featureCollection?: StopsResponse): void;
/**
* Launch a search.
*
* @param {String} q The query to search for.
* @param {AbortController} abortController Abort controller used to cancel the request.
* @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
*/
search(q: string, abortController: AbortController): Promise<void>;
}
export default StopFinderControlCommon;