mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 01:00:05 +00:00
Add type definition of non npm package amap-js-api-arrival-range (#35290)
* [amap-js-api] update to v1.4.14 * Add definition for non npm package: amap-js-api-district-search * Add type definition for non npm-package amap-js-api-line-search * Add type definition of non npm package amap-js-api-arrival-range
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
c2e1a0acce
commit
bdd066eeb8
@@ -0,0 +1,42 @@
|
||||
declare const lnglat: AMap.LngLat;
|
||||
declare const lnglatTuple: [number, number];
|
||||
|
||||
// $ExpectType ArrivalRange
|
||||
const arrivalRange = new AMap.ArrivalRange();
|
||||
|
||||
// $ExpectType void
|
||||
arrivalRange.search(lnglat, 10, (status, result) => {
|
||||
const tempStatus: 'complete' | 'error' | 'no_data' = status;
|
||||
if (typeof result !== 'string') {
|
||||
// $ExpectType SearchResult
|
||||
result;
|
||||
// $ExpectType string
|
||||
result.bounds[0][0][0][0];
|
||||
// $ExpectType boolean[] | undefined
|
||||
result.inRange;
|
||||
// $ExpectType string
|
||||
result.info;
|
||||
// $ExpectType string
|
||||
result.infocode;
|
||||
} else {
|
||||
// $ExpectType string
|
||||
result;
|
||||
}
|
||||
});
|
||||
// $ExpectType void
|
||||
arrivalRange.search(lnglatTuple, 10, () => { });
|
||||
// $ExpectType void
|
||||
arrivalRange.search(lnglatTuple, 10, () => { }, {});
|
||||
// $ExpectType void
|
||||
arrivalRange.search(lnglat, 10, () => { }, {
|
||||
policy: 'BUS',
|
||||
resultType: 'polygon',
|
||||
destination: lnglat
|
||||
});
|
||||
|
||||
arrivalRange.on('error', (event: AMap.ArrivalRange.EventMap['error']) => {
|
||||
// $ExpectType string
|
||||
event.info;
|
||||
// $ExpectType "error"
|
||||
event.type;
|
||||
});
|
||||
66
types/amap-js-api-arrival-range/index.d.ts
vendored
Normal file
66
types/amap-js-api-arrival-range/index.d.ts
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
// Type definitions for non-npm package amap-js-api-arrival-range 1.4
|
||||
// Project: https://lbs.amap.com/api/javascript-api/reference/route-search#m_AMap.ArrivalRange
|
||||
// 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 ArrivalRange {
|
||||
interface EventMap {
|
||||
error: Event<'error', { info: string; }>;
|
||||
}
|
||||
interface SearchOptions {
|
||||
/**
|
||||
* 公交出行策略,可选为:地铁:SUBWAY, 公交:BUS,多策略使用逗号分隔
|
||||
*/
|
||||
policy?: string; // 'BUS' | 'SUBWAY' | 'BUS,SUBWAY' | 'SUBWAY,BUS';
|
||||
/**
|
||||
* 结果返回样式:polygon:返回多边形边界值,coverage:判断设定的终点坐标是否在到达圈范围内
|
||||
*/
|
||||
resultType?: 'polygon' | 'coverage'; // useless
|
||||
/**
|
||||
* 选择一个想到达的目的地坐标,最多支持5个目的地坐标
|
||||
*/
|
||||
destination?: LocationValue | LocationValue[];
|
||||
}
|
||||
interface SearchResult {
|
||||
/**
|
||||
* 查询状态说明
|
||||
*/
|
||||
info: string;
|
||||
/**
|
||||
* 到达圈边界坐标点
|
||||
*/
|
||||
bounds: string[][][][];
|
||||
/**
|
||||
* 提供的终点坐标是否在到达圈内
|
||||
*/
|
||||
inRange?: boolean[];
|
||||
|
||||
// internal
|
||||
infocode: string;
|
||||
}
|
||||
type SearchStatus = 'complete' | 'error' | 'no_data';
|
||||
}
|
||||
|
||||
/**
|
||||
* 公交到达圈展示
|
||||
*/
|
||||
class ArrivalRange extends EventEmitter {
|
||||
/**
|
||||
* 计算某个时间段内用户通过公交出行可到达的距离范围
|
||||
* @param origin 起始点
|
||||
* @param time 时间
|
||||
* @param callback 回调
|
||||
* @param opts 选项
|
||||
*/
|
||||
search(
|
||||
origin: LocationValue,
|
||||
time: number,
|
||||
callback: (status: ArrivalRange.SearchStatus, result: string | ArrivalRange.SearchResult) => void,
|
||||
opts?: ArrivalRange.SearchOptions
|
||||
): void;
|
||||
}
|
||||
}
|
||||
24
types/amap-js-api-arrival-range/tsconfig.json
Normal file
24
types/amap-js-api-arrival-range/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-arrival-range-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/amap-js-api-arrival-range/tslint.json
Normal file
3
types/amap-js-api-arrival-range/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user