mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-09 19:50:08 +00:00
New definition for non npm package amap-js-api-scale (#38760)
This commit is contained in:
committed by
Ryan Cavanaugh
parent
bfab99e84d
commit
b2c017037d
38
types/amap-js-api-scale/amap-js-api-scale-tests.ts
Normal file
38
types/amap-js-api-scale/amap-js-api-scale-tests.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
declare const map: AMap.Map;
|
||||
declare const pixel: AMap.Pixel;
|
||||
|
||||
// $ExpectType Scale
|
||||
new AMap.Scale();
|
||||
// $ExpectType Scale
|
||||
new AMap.Scale({});
|
||||
// $ExpectType Scale
|
||||
const scale = new AMap.Scale({
|
||||
position: 'LT',
|
||||
visible: true,
|
||||
offset: pixel
|
||||
});
|
||||
|
||||
// $ExpectType Pixel
|
||||
scale.offset;
|
||||
|
||||
// $ExpectType boolean
|
||||
scale.visible;
|
||||
|
||||
// $ExpectType Position
|
||||
scale.position;
|
||||
|
||||
// $ExpectType void
|
||||
scale.show();
|
||||
|
||||
// $ExpectType void
|
||||
scale.hide();
|
||||
|
||||
scale.on('show', (event: AMap.Scale.EventMap['show']) => {
|
||||
// $ExpectType "show"
|
||||
event.type;
|
||||
});
|
||||
|
||||
scale.on('hide', (event: AMap.Scale.EventMap['hide']) => {
|
||||
// $ExpectType "hide"
|
||||
event.type;
|
||||
});
|
||||
63
types/amap-js-api-scale/index.d.ts
vendored
Normal file
63
types/amap-js-api-scale/index.d.ts
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// Type definitions for non-npm package amap-js-api-scale 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/map-control#AMap.Scale
|
||||
// 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 Scale {
|
||||
interface EventMap {
|
||||
show: Event<'show'>;
|
||||
hide: Event<'hide'>;
|
||||
}
|
||||
type Position = 'LT' | 'RT' | 'LB' | 'RB';
|
||||
interface Options {
|
||||
/**
|
||||
* 控件停靠位置
|
||||
* LT:左上角;
|
||||
* RT:右上角;
|
||||
* LB:左下角;
|
||||
* RB:右下角;
|
||||
* 默认位置:LB
|
||||
*/
|
||||
position?: Position;
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
visible?: boolean;
|
||||
/**
|
||||
* 相对于地图容器左上角的偏移量
|
||||
*/
|
||||
offset?: Pixel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 比例尺插件
|
||||
*/
|
||||
class Scale extends EventEmitter {
|
||||
constructor(options?: Scale.Options);
|
||||
/**
|
||||
* 控件停靠位置
|
||||
*/
|
||||
position: Position;
|
||||
/**
|
||||
* 相对于地图容器左上角的偏移量
|
||||
*/
|
||||
offset: Pixel;
|
||||
/**
|
||||
* 是否可见
|
||||
*/
|
||||
visible: boolean;
|
||||
/**
|
||||
* 显示比例尺
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* 隐藏比例尺
|
||||
*/
|
||||
hide(): void;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-scale/tsconfig.json
Normal file
24
types/amap-js-api-scale/tsconfig.json
Normal file
@@ -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-scale-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/amap-js-api-scale/tslint.json
Normal file
3
types/amap-js-api-scale/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user