Skip to content

Commit dea4c4b

Browse files
authored
fix(autocomplete): update AutoComplete plugin dts (#391)
1 parent 4bc7e71 commit dea4c4b

File tree

1 file changed

+33
-15
lines changed

1 file changed

+33
-15
lines changed

packages/types/src/services.d.ts

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ declare namespace AMap {
249249
}
250250
/**
251251
* 根据输入关键字提示匹配信息,可将Poi类型和城市作为输入提示的限制条件。用户可以通过自定义回调函数取回并显
252+
*
253+
* @see https://lbs.amap.com/api/javascript-api-v2/guide/services/autocomplete
252254
*/
253255
class AutoComplete extends MapEventListener<'choose' | 'select'> {
254256
constructor(opts: AutoCompleteOptions);
@@ -259,30 +261,46 @@ declare namespace AMap {
259261
/** 设置是否强制限制城市 */
260262
setCityLimit(citylimit: boolean): void;
261263
/** 设置是否强制限制城市 */
262-
search(keyword?: string, callback?: (status: 'complete' | 'error' | 'no_data', result?: AutoCompleteSearchCallback) => void): void;
264+
search(keyword: string, callback: (status: 'complete' | 'error' | 'no_data', result: AutoCompleteSearchResult) => void): void;
263265
}
264-
interface AutoCompleteSearchCallback {
266+
interface Tip {
267+
/** 名称 */
268+
name: string;
269+
/** 所属区域 */
270+
district: string;
271+
/** 区域编码 */
272+
adcode: string;
273+
/** 地址 */
274+
address: string;
275+
/** 城市 */
276+
city: any[];
277+
/** ID */
278+
id: string;
279+
/** 坐标经纬度 */
280+
location: LngLat;
281+
/** 类型编码 */
282+
typecode: string;
283+
}
284+
interface AutoCompleteSearchResult {
265285
/** 查询状态说明 */
266286
info: string;
267287
/** 输入提示条数 */
268288
count: number;
269289
/** 输入提示列表 */
270-
tips: Array<{
271-
/** 名称 */
272-
name: string;
273-
/** 所属区域 */
274-
district: string;
275-
/** 区域编码 */
276-
adcode: string;
277-
}>
290+
tips: Array<Tip>;
278291
}
279292
interface AutoCompleteOptions {
280293
/** 输入提示时限定POI类型,多个类型用“|”分隔,目前只支持Poi类型编码如“050000” 默认值:所有类别 */
281294
type?: string;
282295
/** 输入提示时限定城市。可选值:城市名(中文或中文全拼)、citycode、adcode;默认值:“全国” */
283296
city?: string;
284-
/** 返回的数据类型。可选值:all-返回所有数据类型、poi-返回POI数据类型、bus-返回公交站点数据类型、busline-返回公交线路数据类型目前暂时不支持多种类型 */
285-
datatype?: string;
297+
/** 返回的数据类型。可选值:
298+
* - `all` 返回所有数据类型
299+
* - `poi` 返回POI数据类型
300+
* - `bus` 返回公交站点数据类型
301+
* - `busline` 返回公交线路数据类型目前暂时不支持多种类型
302+
*/
303+
datatype?: 'all' | 'bus' | 'poi' | 'busline';
286304
/** 是否强制限制在设置的城市内搜索,默认值为:false,true:强制限制设定城市,false:不强制限制设定城市 */
287305
citylimit?: boolean;
288306
/** 可选参数,用来指定一个input输入框,设定之后,在input输入文字将自动生成下拉选择列表。支持传入输入框DOM对象的id值,或直接传入输入框的DOM对象。 */
@@ -318,8 +336,8 @@ declare namespace AMap {
318336
}
319337

320338
/**
321-
* 根据输入关键字提示匹配信息,可将Poi类型和城市作为输入提示的限制条件。用户可以通过自定义回调函数取回并显
322-
*/
339+
* 根据输入关键字提示匹配信息,可将Poi类型和城市作为输入提示的限制条件。用户可以通过自定义回调函数取回并显
340+
*/
323341
class Autocomplete extends MapEventListener<'choose' | 'select'> {
324342
constructor(opts: AutoCompleteOptions);
325343
/** 设置提示Poi类型,多个类型用“|”分隔,POI相关类型请在网站“相关下载”处下载,目前只支持Poi类型编码如“050000” 默认值:所有类别 */
@@ -329,7 +347,7 @@ declare namespace AMap {
329347
/** 设置是否强制限制城市 */
330348
setCityLimit(citylimit: boolean): void;
331349
/** 设置是否强制限制城市 */
332-
search(keyword?: string, callback?: (status: 'complete' | 'error' | 'no_data', result?: AutoCompleteSearchCallback) => void): void;
350+
search(keyword: string, callback: (status: 'complete' | 'error' | 'no_data', result: AutoCompleteSearchResult) => void): void;
333351
}
334352
/** 地点搜索服务插件,提供某一特定地区的位置查询服务。 */
335353
class PlaceSearch extends MapEventListener<'selectChanged' | 'listElementClick' | 'markerClick'> {

0 commit comments

Comments
 (0)