Files
xbcr/src-ts/types/bmapgl.d.ts
T
zzy 8ece55983a feat(前端): TypeScript 重写版(esbuild IIFE 产物,暂不接管线上)
- 新增 src-ts/(22 个 .ts / 7792 行):按 core / map / card / order / nav / share /
  subscribe / ui / compat 分层,types 里有 BMapGL 与 API 响应声明
- compat/globals.ts 是唯一挂 window 的地方(292 个),覆盖模板 139 处内联事件
- esbuild 产出 static/dist/app.js(226.6 KiB,IIFE,es2019)+ README(构建/切换/回滚)
- 构建可复现:node esbuild.config.mjs、node --check、npx tsc --noEmit 均通过
- .gitignore 增加 node_modules/ 与 static/dist/*.map(sourcemap 可重生成,不入库)
- 暂不改 templates/map.html 与 MAP_ASSETS:等独立核对通过再切换,回滚=换回四个 script
2026-11-16 10:44:11 +08:00

89 lines
2.4 KiB
TypeScript

/* BMapGL(百度地图 JS API GL 版)最小类型声明。
*
* 只声明 static/js 里**实际用到**的成员;其余一律靠索引签名放行,
* 这样既不丢类型检查(构造函数/常用方法有签名),又不用为整个 SDK 写声明。
*
* 实际用到的:Map / Marker / Polyline / Polygon / Circle / Icon / Point / Size /
* ViewAnimation / ScaleControl / WalkingRoute / Overlay / Convertor
* 说明:bike-clusters.js 里还用了 BMapGL.Overlay(外部脚本自己声明,不进 bundle)。
*/
declare namespace BMapGL {
/** 构造选项一律宽松处理。 */
type Opts = Record<string, any>;
class Point {
constructor(lng: number, lat: number);
lng: number;
lat: number;
equals(other: any): boolean;
[key: string]: any;
}
class Size {
constructor(width: number, height: number);
width: number;
height: number;
[key: string]: any;
}
class Icon {
constructor(imageUrl: string, size: Size, opts?: Size | Opts);
[key: string]: any;
}
class Marker {
constructor(point: Point, opts?: Opts);
[key: string]: any;
}
class Polyline {
constructor(points: Point[], opts?: Opts);
[key: string]: any;
}
class Polygon {
constructor(points: Point[], opts?: Opts);
[key: string]: any;
}
class Circle {
constructor(center: Point, radius: number, opts?: Opts);
[key: string]: any;
}
class Overlay {
constructor(opts?: Opts);
[key: string]: any;
}
class ScaleControl {
constructor(opts?: Opts);
[key: string]: any;
}
/** 视野动画(朝向/缩放过渡),navigation.js 用 new BMapGL.ViewAnimation([...], {duration}) */
class ViewAnimation {
constructor(opts: any, opts2?: any);
[key: string]: any;
}
/** 步行路线规划:navigation.js 用于精算步行距离 */
class WalkingRoute {
constructor(map: Map, opts?: Opts);
search(start: any, end: any): void;
[key: string]: any;
}
/** 在线坐标转换接口(本项目已改用 coordtransform.js,保留声明以免整库报错) */
class Convertor {
constructor(opts?: Opts);
[key: string]: any;
}
class Map {
constructor(container: string | HTMLElement, opts?: Opts);
[key: string]: any;
}
}