diff --git a/types/amap-js-api-overview/amap-js-api-overview-tests.ts b/types/amap-js-api-overview/amap-js-api-overview-tests.ts new file mode 100644 index 0000000000..f0d4c09708 --- /dev/null +++ b/types/amap-js-api-overview/amap-js-api-overview-tests.ts @@ -0,0 +1,52 @@ +declare const map: AMap.Map; + +declare const tileLayer: AMap.TileLayer; + +// $ExpectType OverView +new AMap.OverView(); +// $ExpectType OverView +new AMap.OverView({}); +// $ExpectType OverView +const overview = new AMap.OverView({ + tileLayer, + isOpen: true, + visible: true +}); + +// $ExpectType void +overview.show(); + +// $ExpectType void +overview.hide(); + +// $ExpectType void +overview.open(); + +// $ExpectType void +overview.close(); + +// $ExpectType void +overview.setTileLayer(tileLayer); + +// $ExpectType TileLayer +overview.getTileLayer(); + +overview.on('show', (event: AMap.OverView.EventMap['show']) => { + // $ExpectType "show" + event.type; +}); + +overview.on('hide', (event: AMap.OverView.EventMap['hide']) => { + // $ExpectType "hide" + event.type; +}); + +overview.on('open', (event: AMap.OverView.EventMap['open']) => { + // $ExpectType "open" + event.type; +}); + +overview.on('close', (event: AMap.OverView.EventMap['close']) => { + // $ExpectType "close" + event.type; +}); diff --git a/types/amap-js-api-overview/index.d.ts b/types/amap-js-api-overview/index.d.ts new file mode 100644 index 0000000000..91c1347b2c --- /dev/null +++ b/types/amap-js-api-overview/index.d.ts @@ -0,0 +1,64 @@ +// Type definitions for non-npm package amap-js-api-overview 1.4 +// Project: https://lbs.amap.com/api/javascript-api/reference/map-control#AMap.OverView +// Definitions by: breeze9527 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +/// + +declare namespace AMap { + namespace OverView { + interface EventMap { + show: Event<'show'>; + hide: Event<'hide'>; + open: Event<'open'>; + close: Event<'close'>; + } + interface Options { + /** + * 鹰眼窗体中需显示的切片图层 + */ + tileLayer?: L; + /** + * 鹰眼是否展开,默认为false + */ + isOpen?: boolean; + /** + * 鹰眼是否显示,默认为true + */ + visible?: boolean; + } + } + + /** + * 地图鹰眼插件 + */ + class OverView extends EventEmitter { + constructor(options?: OverView.Options); + /** + * 显示鹰眼窗体 + */ + show(): void; + /** + * 隐藏鹰眼窗体 + */ + hide(): void; + /** + * 展开鹰眼窗口 + */ + open(): void; + /*** + * 折叠鹰眼窗口 + */ + close(): void; + /** + * 设置鹰眼中需显示的切片图层 + * @param tileLayer 切片图层 + */ + setTileLayer(tileLayer: L): void; + /** + * 获取窗体中显示的切片图层 + */ + getTileLayer(): L; + } +} diff --git a/types/amap-js-api-overview/tsconfig.json b/types/amap-js-api-overview/tsconfig.json new file mode 100644 index 0000000000..dd9e0e918e --- /dev/null +++ b/types/amap-js-api-overview/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "amap-js-api-overview-tests.ts" + ] +} diff --git a/types/amap-js-api-overview/tslint.json b/types/amap-js-api-overview/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/amap-js-api-overview/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}