DefinitelyTyped/types/amap-js-api-district-search/index.d.ts
breeze9527 bed07e18ca Add definition for non npm package: amap-js-api-district-search (#34856)
* [amap-js-api] update to v1.4.14

* Add definition for non npm package: amap-js-api-district-search
2019-04-19 12:58:51 -07:00

109 lines
3.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Type definitions for non-npm package amap-js-api-district-search 1.4
// Project: https://lbs.amap.com/api/javascript-api/reference/search#m_AMap.DistrictSearch
// Definitions by: breeze9527 <https://github.com/breeze9527>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/// <reference types="amap-js-api" />
declare namespace AMap {
namespace DistrictSearch {
interface EventMap {
error: Event<'error', { info: string; }>;
complete: Event<'complete', SearchResult>;
}
type Level = 'country' | 'province' | 'city' | 'district' | 'biz_area';
interface Options {
/**
* 关键字对应的行政区级别或商圈
*/
level?: Level;
/**
* 是否显示商圈
*/
showbiz?: boolean;
/**
* 是否返回行政区边界坐标点
*/
extensions?: 'base' | 'all';
/**
* 显示下级行政区级数
* 0不返回下级行政区
* 1返回下一级行政区
* 2返回下两级行政区
* 3返回下三级行政区
*/
subdistrict?: 0 | 1 | 2 | 3;
}
interface District {
/**
* 行政区名称
*/
name: string;
/**
* 中心点经纬度坐标
*/
center: LngLat;
/**
* 城市编码
*/
citycode: string;
/**
* 区域编码
*/
adcode: string;
/**
* 行政区划级别
*/
level: Level;
/**
* 边界坐标集合
*/
boundaries?: LngLat[][];
/**
* 下级行政区信息列表
*/
districtList?: District[];
}
interface SearchResult {
/**
* 成功状态文字描述
*/
info: string;
/**
* 行政区划列表
*/
districtList: District[];
}
type SearchStatus = 'complete' | 'error' | 'no_data';
}
class DistrictSearch extends EventEmitter {
/**
* 行政区查询
* @param options 选项
*/
constructor(options?: DistrictSearch.Options);
/**
* 根据关键字查询行政区或商圈信息
* @param keyword 关键词
* @param callback 回调
*/
search(
keyword: string,
callback: (status: DistrictSearch.SearchStatus, result: DistrictSearch.SearchResult | string) => void
): void;
/**
* 设置关键字对应的行政区级别或商圈
* @param level 级别
*/
setLevel(level?: DistrictSearch.Level): void;
/**
* 设置下级行政区级数
* @param district 级数
*/
setSubdistrict(district?: 0 | 1 | 2 | 3): void;
// internal
setExtensions(extensions?: boolean): void;
}
}