[amap-js-api] Update constructor of AMap.Bounds

This commit is contained in:
breeze9527
2019-04-11 20:41:01 +08:00
parent 55ece09ae5
commit c7c036dc21
3 changed files with 32 additions and 10 deletions

View File

@@ -60,6 +60,16 @@ testArrayBounds.getCenter();
// $ExpectType Bounds
const testBounds = new AMap.Bounds(lnglat, lnglat);
// $ExpectType Bounds
new AMap.Bounds();
// $ExpectError
new AMap.Bounds([0, 0, 0]);
// $ExpectType Bounds
new AMap.Bounds([0, 0, 0, 0]);
// $ExpectType Bounds
new AMap.Bounds(lnglatTuple, lnglatTuple);
// $ExpectType Bounds
new AMap.Bounds(0, 0, 0, 0);
// $ExpectType boolean
testBounds.contains(lnglat);

View File

@@ -1,11 +1,24 @@
declare namespace AMap {
class Bounds {
/**
* 地物对象的经纬度矩形范围。
* @param coords 由西南角,东北角经纬度组成的数组,分别是[西南角经度, 西南角纬度,东北角经度,东北角纬度]
*/
constructor(coords?: [number, number, number, number]);
/**
* 地物对象的经纬度矩形范围。
* @param southWest 西南角经纬度
* @param northEast 东北角经纬度
*/
constructor(southWest: LngLat, northEast: LngLat);
constructor(southWest: LocationValue, northEast: LocationValue);
/**
* 地物对象的经纬度矩形范围。
* @param southWestLng 西南角经度
* @param southWestLat 西南角纬度
* @param northEastLng 东北角经度
* @param northEastLat 东北角纬度
*/
constructor(southWestLng: number, southWestLat: number, northEastLng: number, northEastLat: number);
/**
* 指定点坐标是否在矩形范围内
* @param point 制定坐标

View File

@@ -8,10 +8,9 @@ declare namespace AMap {
* @param once 触发一次
* @param unshift 更改事件顺序
*/
on<E extends Event, C = this>(
on<C = this>(
eventName: string,
// tslint:disable-next-line:no-unnecessary-generics
handler: (this: C, event: E) => void,
handler: (this: C, event: any) => void,
context?: C,
once?: boolean,
unshift?: boolean
@@ -22,10 +21,10 @@ declare namespace AMap {
* @param handler 事件功能函数
* @param context 事件上下文
*/
off<E extends Event, C = this>(
off<C = this>(
eventName: string,
// tslint:disable-next-line
handler: ((this: C, event: E) => void) | 'mv',
handler: ((this: C, event: any) => void) | 'mv',
context?: C
): this;
/**
@@ -61,12 +60,12 @@ declare namespace AMap {
* @param handler 事件功能函数
* @param context 事件上下文
*/
function addListener<I extends EventEmitter, E extends Event, C = I>(
function addListener<I extends EventEmitter, C = I>(
// tslint:disable-next-line: no-unnecessary-generics
instance: I,
eventName: string,
// tslint:disable-next-line: no-unnecessary-generics
handler: (this: C, event: E) => void,
handler: (this: C, event: any) => void,
// tslint:disable-next-line: no-unnecessary-generics
context?: C
): EventListener<1>;
@@ -77,12 +76,12 @@ declare namespace AMap {
* @param handler 事件功能函数
* @param context 事件上下文
*/
function addListenerOnce<I extends EventEmitter, E extends Event, C = I>(
function addListenerOnce<I extends EventEmitter, C = I>(
// tslint:disable-next-line: no-unnecessary-generics
instance: I,
eventName: string,
// tslint:disable-next-line: no-unnecessary-generics
handler: (this: C, event: E) => void,
handler: (this: C, event: any) => void,
// tslint:disable-next-line: no-unnecessary-generics
context?: C
): EventListener<1>;