@terra.gl/core 0.0.1-alpha.51 → 0.0.1-alpha.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +41 -145
- package/dist/index.js +566 -596
- package/dist/index.umd.cjs +18 -17
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -274,19 +274,10 @@ export declare type AttributesType = {
|
|
|
274
274
|
|
|
275
275
|
export declare const author: any;
|
|
276
276
|
|
|
277
|
-
/**
|
|
278
|
-
* @category DrawTool
|
|
279
|
-
*/
|
|
280
277
|
declare type BaseDrawToolOptions = MapToolOptions & {
|
|
281
|
-
/**
|
|
282
|
-
* Mode name, e.g. 'line' / 'polygon' / 'point'
|
|
283
|
-
* 模式名称,例如 'line' / 'polygon' / 'point'
|
|
284
|
-
*/
|
|
278
|
+
/** 模式名称,例如 'line' / 'polygon' / 'point' */
|
|
285
279
|
mode: string;
|
|
286
|
-
/**
|
|
287
|
-
* Whether to automatically disable tool after one drawing finishes
|
|
288
|
-
* 是否在一次绘制结束后自动禁用工具
|
|
289
|
-
*/
|
|
280
|
+
/** 是否在一次绘制结束后自动禁用工具 */
|
|
290
281
|
once?: boolean;
|
|
291
282
|
};
|
|
292
283
|
|
|
@@ -1160,15 +1151,12 @@ declare interface DomEventMap extends BaseEventMap<Map_2> {
|
|
|
1160
1151
|
}
|
|
1161
1152
|
|
|
1162
1153
|
/**
|
|
1163
|
-
* Single draw mode definition:
|
|
1164
1154
|
* 单个绘制模式定义:
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1169
|
-
*
|
|
1170
|
-
* @property clickLimit - Minimum click count (can finish when reached, usually with dblclick) 最少点击次数(达到就可以结束,通常配合 dblclick)
|
|
1171
|
-
* @category DrawTool
|
|
1155
|
+
* - actions: 参与的事件序列(目前主要是 click / mousemove / dblclick)
|
|
1156
|
+
* - create: 第一次点击时创建几何对象
|
|
1157
|
+
* - update: 每次新增顶点或移动时更新几何
|
|
1158
|
+
* - generate: 结束时生成最终结果(可以是 Feature,也可以是原几何)
|
|
1159
|
+
* - clickLimit: 最少点击次数(达到就可以结束,通常配合 dblclick)
|
|
1172
1160
|
*/
|
|
1173
1161
|
declare type DrawModeDefinition = {
|
|
1174
1162
|
actions: Array<"click" | "mousemove" | "dblclick">;
|
|
@@ -1179,86 +1167,51 @@ declare type DrawModeDefinition = {
|
|
|
1179
1167
|
};
|
|
1180
1168
|
|
|
1181
1169
|
/**
|
|
1182
|
-
* DrawTool: Universal Drawing Tool
|
|
1183
1170
|
* DrawTool:通用绘图工具
|
|
1184
1171
|
*
|
|
1185
|
-
* @description
|
|
1186
|
-
* Responsible for:
|
|
1187
|
-
* - Handling Map DOM events (click/mousemove/dblclick)
|
|
1188
|
-
* - Maintaining vertex sequence _clickCoords
|
|
1189
|
-
* - Calling mode definitions create/update/generate
|
|
1190
|
-
* - Triggering events: drawstart / drawvertex / drawend / drawing, etc.
|
|
1191
|
-
*
|
|
1192
1172
|
* 负责:
|
|
1193
1173
|
* - 处理 Map 的 DOM 事件(click/mousemove/dblclick)
|
|
1194
1174
|
* - 维护顶点序列 _clickCoords
|
|
1195
1175
|
* - 调用模式定义的 create/update/generate
|
|
1196
|
-
* - 向外触发:drawstart / drawend / drawing 等事件
|
|
1197
|
-
* @category DrawTool
|
|
1176
|
+
* - 向外触发:drawstart / drawvertex / drawend / drawing 等事件
|
|
1198
1177
|
*/
|
|
1199
1178
|
export declare class DrawTool extends MapTool {
|
|
1200
|
-
/**
|
|
1201
|
-
* Configuration options
|
|
1202
|
-
* 配置
|
|
1203
|
-
*/
|
|
1179
|
+
/** 配置 */
|
|
1204
1180
|
options: DrawToolOptions;
|
|
1205
|
-
/**
|
|
1206
|
-
* Current mode definition
|
|
1207
|
-
* 当前模式定义
|
|
1208
|
-
*/
|
|
1181
|
+
/** 当前模式定义 */
|
|
1209
1182
|
private _modeDef?;
|
|
1210
|
-
/**
|
|
1211
|
-
* Current drawing vertex sequence
|
|
1212
|
-
* 当前绘制中的顶点序列
|
|
1213
|
-
*/
|
|
1183
|
+
/** 当前绘制中的顶点序列 */
|
|
1214
1184
|
private _clickCoords;
|
|
1215
|
-
/**
|
|
1216
|
-
* Whether drawing is in progress
|
|
1217
|
-
* 是否正在绘制中
|
|
1218
|
-
*/
|
|
1185
|
+
/** 是否正在绘制中 */
|
|
1219
1186
|
private _isDrawing;
|
|
1220
|
-
/**
|
|
1221
|
-
* Current drawing geometry object (returned by mode.create/create)
|
|
1222
|
-
* 当前绘制中的几何对象(由 mode.create/create 返回)
|
|
1223
|
-
*/
|
|
1187
|
+
/** 当前绘制中的几何对象(由 mode.create/create 返回) */
|
|
1224
1188
|
private _geometry;
|
|
1225
|
-
/**
|
|
1226
|
-
* Internal unified draft layer
|
|
1227
|
-
* 内部统一草图图层
|
|
1228
|
-
*/
|
|
1189
|
+
/** 内部统一草图图层 */
|
|
1229
1190
|
private _draftLayer?;
|
|
1230
1191
|
/**
|
|
1231
|
-
* Register a drawing mode
|
|
1232
1192
|
* 注册一个绘制模式
|
|
1233
1193
|
*/
|
|
1234
1194
|
static registerMode(name: string, def: DrawModeDefinition): void;
|
|
1235
1195
|
/**
|
|
1236
|
-
* Get registered mode definition
|
|
1237
1196
|
* 获取已注册的模式
|
|
1238
1197
|
*/
|
|
1239
1198
|
static getModeDefinition(name: string): DrawModeDefinition | undefined;
|
|
1240
1199
|
constructor(options: DrawToolOptions);
|
|
1241
1200
|
/**
|
|
1242
|
-
* Get current mode name (unified to lowercase)
|
|
1243
1201
|
* 获取当前模式名称(统一转为小写)
|
|
1244
1202
|
*/
|
|
1245
1203
|
getMode(): string;
|
|
1246
1204
|
/**
|
|
1247
|
-
* Set drawing mode: will clear current drawing state
|
|
1248
1205
|
* 设置绘制模式:会清空当前绘制状态
|
|
1249
1206
|
*/
|
|
1250
1207
|
setMode(mode: string): this;
|
|
1251
1208
|
/**
|
|
1252
|
-
* Set drawing style (only affects subsequent new drawings)
|
|
1253
1209
|
* 设置绘制样式(仅影响后续新开始的绘制)
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
* @param style.geometryStyle - Main geometry style (point/line/polygon) 主几何样式(点/线/面)
|
|
1257
|
-
* @param style.vertexStyle - Vertex style, pass null to disable anchor display 顶点样式,传 null 可关闭锚点显示
|
|
1210
|
+
* - geometryStyle:主几何样式(点/线/面)
|
|
1211
|
+
* - vertexStyle:顶点样式,传 null 可关闭锚点显示
|
|
1258
1212
|
*/
|
|
1259
1213
|
setStyle(style: DrawToolStyleOptions): this;
|
|
1260
1214
|
/**
|
|
1261
|
-
* Subclass implementation: Return event mapping to bind to Map
|
|
1262
1215
|
* 子类实现:返回需要绑定到 Map 的事件映射
|
|
1263
1216
|
*/
|
|
1264
1217
|
protected getEvents(): {
|
|
@@ -1267,67 +1220,44 @@ export declare class DrawTool extends MapTool {
|
|
|
1267
1220
|
dblclick: (evt: DomEventMap) => void;
|
|
1268
1221
|
};
|
|
1269
1222
|
/**
|
|
1270
|
-
* Sync mode definition when enabled
|
|
1271
1223
|
* 启用时同步一下模式定义
|
|
1272
1224
|
*/
|
|
1273
1225
|
protected onEnable(): void;
|
|
1274
1226
|
/**
|
|
1275
|
-
* Finish current drawing and clean up draft layer when disabled
|
|
1276
1227
|
* 禁用时结束当前绘制,并清理草图图层
|
|
1277
1228
|
*/
|
|
1278
1229
|
protected onDisable(): void;
|
|
1279
1230
|
/**
|
|
1280
|
-
* Ensure current mode has corresponding definition
|
|
1281
1231
|
* 确保当前 mode 有对应的定义
|
|
1282
1232
|
*/
|
|
1283
1233
|
private _ensureMode;
|
|
1284
1234
|
/**
|
|
1285
|
-
* Handle click event:
|
|
1286
1235
|
* 处理 click 事件:
|
|
1287
|
-
*
|
|
1288
|
-
* @description
|
|
1289
|
-
* - First click: Start drawing, call mode.create, trigger drawstart
|
|
1290
|
-
* - Subsequent click: Append vertex, call mode.update, trigger drawvertex
|
|
1291
|
-
* - If clickLimit reached: Finish drawing
|
|
1292
|
-
*
|
|
1293
1236
|
* - 第一次 click:开始绘制,调用 mode.create,触发 drawstart
|
|
1294
1237
|
* - 后续 click:追加顶点,调用 mode.update,触发 drawvertex
|
|
1295
1238
|
* - 若达到 clickLimit,则结束绘制
|
|
1296
1239
|
*/
|
|
1297
1240
|
private _handleClick;
|
|
1298
1241
|
/**
|
|
1299
|
-
* Handle mousemove event:
|
|
1300
1242
|
* 处理 mousemove 事件:
|
|
1301
|
-
*
|
|
1302
|
-
* @description
|
|
1303
|
-
* - Only update geometry when drawing
|
|
1304
|
-
* - Do not modify _clickCoords, use temporary coords for update
|
|
1305
|
-
*
|
|
1306
1243
|
* - 仅在绘制中才更新几何
|
|
1307
1244
|
* - 不修改 _clickCoords,只用临时 coords 传给 update
|
|
1308
1245
|
*/
|
|
1309
1246
|
private _handleMouseMove;
|
|
1310
1247
|
/**
|
|
1311
|
-
* Handle dblclick:
|
|
1312
1248
|
* 处理 dblclick:
|
|
1313
|
-
*
|
|
1314
|
-
* @description
|
|
1315
|
-
* - If drawing, finish directly
|
|
1316
1249
|
* - 如果正在绘制,则直接结束
|
|
1317
1250
|
*/
|
|
1318
1251
|
private _handleDblClick;
|
|
1319
1252
|
/**
|
|
1320
|
-
* Normally finish a drawing: Call mode.generate and trigger drawend
|
|
1321
1253
|
* 正常结束一次绘制:调用 mode.generate 并触发 drawend
|
|
1322
1254
|
*/
|
|
1323
1255
|
private _finishDrawing;
|
|
1324
1256
|
/**
|
|
1325
|
-
* Silently finish (no drawend trigger), used for mode switching / tool disabling
|
|
1326
1257
|
* 静默结束(不触发 drawend),用于切换模式 / 禁用工具
|
|
1327
1258
|
*/
|
|
1328
1259
|
private _finishDrawingSilently;
|
|
1329
1260
|
/**
|
|
1330
|
-
* Internal: Get or create unified draft layer
|
|
1331
1261
|
* 内部:获取或创建统一草图图层
|
|
1332
1262
|
*/
|
|
1333
1263
|
_getOrCreateDraftLayer(): OverlayLayer<Feature>;
|
|
@@ -1340,23 +1270,13 @@ export declare class DrawTool extends MapTool {
|
|
|
1340
1270
|
export declare type DrawToolOptions = BaseDrawToolOptions & DrawToolStyleOptions;
|
|
1341
1271
|
|
|
1342
1272
|
/**
|
|
1343
|
-
* Style configuration type
|
|
1344
1273
|
* 样式配置类型
|
|
1345
|
-
* @category DrawTool
|
|
1346
1274
|
*/
|
|
1347
1275
|
export declare type DrawToolStyleOptions = {
|
|
1348
|
-
/**
|
|
1349
|
-
* Main geometry style (point / line / polygon)
|
|
1350
|
-
* 主几何样式(点 / 线 / 面)
|
|
1351
|
-
*/
|
|
1276
|
+
/** 主几何样式(点 / 线 / 面) */
|
|
1352
1277
|
geometryStyle?: StyleInput;
|
|
1353
1278
|
/**
|
|
1354
|
-
* Vertex (anchor) style
|
|
1355
1279
|
* 顶点(锚点)样式
|
|
1356
|
-
*
|
|
1357
|
-
* @description
|
|
1358
|
-
* - Pass null to not draw anchors
|
|
1359
|
-
* - Pass undefined to keep current setting
|
|
1360
1280
|
* - 传 null 表示不绘制锚点
|
|
1361
1281
|
* - 不传该字段则保持当前设置
|
|
1362
1282
|
*/
|
|
@@ -4268,100 +4188,78 @@ export declare type MapOptionsType = {
|
|
|
4268
4188
|
};
|
|
4269
4189
|
|
|
4270
4190
|
/**
|
|
4271
|
-
* Map Tool Base Class.
|
|
4272
4191
|
* 地图工具基类
|
|
4273
4192
|
*
|
|
4274
|
-
* - Manage tool lifecycle (addTo / enable / disable / remove)
|
|
4275
|
-
* - Integrate with Map event system (Unified internal event registration/unregistration)
|
|
4276
|
-
* - Ensure only one active tool exists on the same map
|
|
4277
|
-
*
|
|
4278
4193
|
* - 管理工具的生命周期(addTo / enable / disable / remove)
|
|
4279
4194
|
* - 与 Map 的事件系统对接(内部统一注册/注销事件)
|
|
4280
4195
|
* - 保证同一张地图同时只存在一个激活工具
|
|
4281
|
-
* @category Map
|
|
4282
4196
|
*/
|
|
4283
4197
|
export declare abstract class MapTool extends MapTool_base {
|
|
4284
|
-
/**
|
|
4285
|
-
* Bound map instance
|
|
4286
|
-
* 绑定的地图实例
|
|
4287
|
-
*/
|
|
4198
|
+
/** 绑定的地图实例 */
|
|
4288
4199
|
protected _map?: Map_2;
|
|
4289
|
-
/**
|
|
4290
|
-
* Whether enabled
|
|
4291
|
-
* 是否启用中
|
|
4292
|
-
*/
|
|
4200
|
+
/** 是否启用中 */
|
|
4293
4201
|
protected _enabled: boolean;
|
|
4294
|
-
/**
|
|
4295
|
-
* Cache event handlers bound to Map for removal on off
|
|
4296
|
-
* 缓存绑定到 Map 上的事件处理函数,便于 off 时移除
|
|
4297
|
-
*/
|
|
4202
|
+
/** 缓存绑定到 Map 上的事件处理函数,便于 off 时移除 */
|
|
4298
4203
|
private _boundHandlers;
|
|
4299
4204
|
/**
|
|
4300
|
-
* @param options
|
|
4205
|
+
* @param options 工具配置
|
|
4301
4206
|
*/
|
|
4302
4207
|
constructor(options?: MapToolOptions);
|
|
4303
4208
|
/**
|
|
4304
|
-
* Add tool to map and automatically enable.
|
|
4305
|
-
* Ensures only one active MapTool on the same Map.
|
|
4306
4209
|
* 将工具添加到地图上,并自动启用。
|
|
4307
4210
|
* 同一张 Map 上会保证只有一个激活的 MapTool。
|
|
4308
4211
|
*/
|
|
4309
4212
|
addTo(map: Map_2): this;
|
|
4310
4213
|
/**
|
|
4311
|
-
* Get currently bound map instance.
|
|
4312
4214
|
* 获取当前绑定的地图实例
|
|
4313
4215
|
*/
|
|
4314
4216
|
getMap(): Map_2 | undefined;
|
|
4315
4217
|
/**
|
|
4316
|
-
* Enable tool: Bind events + Call onEnable hook.
|
|
4317
4218
|
* 启用工具:绑定事件 + 调用 onEnable 钩子
|
|
4318
4219
|
*/
|
|
4319
4220
|
enable(): this;
|
|
4320
4221
|
/**
|
|
4321
|
-
* Disable tool: Unbind events + Call onDisable hook.
|
|
4322
4222
|
* 禁用工具:解绑事件 + 调用 onDisable 钩子
|
|
4323
4223
|
*/
|
|
4324
4224
|
disable(): this;
|
|
4325
4225
|
/**
|
|
4326
|
-
*
|
|
4327
|
-
|
|
4226
|
+
* 工具是否处于启用状态
|
|
4227
|
+
*/
|
|
4228
|
+
isEnabled(): boolean;
|
|
4229
|
+
/**
|
|
4230
|
+
* 从地图上移除工具
|
|
4328
4231
|
*/
|
|
4329
4232
|
remove(): this;
|
|
4330
4233
|
/**
|
|
4331
|
-
*
|
|
4332
|
-
*
|
|
4234
|
+
* 子类实现:返回需要绑定到 Map 上的事件映射
|
|
4235
|
+
*
|
|
4236
|
+
* key: 事件名(如 'click', 'mousemove')
|
|
4237
|
+
* value: 事件处理函数(参数为 Map 的事件数据)
|
|
4238
|
+
*
|
|
4239
|
+
* 注意:
|
|
4240
|
+
* - 不要求提前 bind(this),MapTool 内部会统一绑定 this
|
|
4241
|
+
*/
|
|
4242
|
+
protected abstract getEvents(): Record<string, (e: any) => void>;
|
|
4243
|
+
/**
|
|
4244
|
+
* 生命周期钩子:工具刚 addTo(map) 时调用
|
|
4333
4245
|
*/
|
|
4334
4246
|
protected onAdd?(): void;
|
|
4335
4247
|
/**
|
|
4336
|
-
*
|
|
4337
|
-
* 抽象方法:子类可实现启用逻辑。
|
|
4248
|
+
* 生命周期钩子:工具 enable() 时调用
|
|
4338
4249
|
*/
|
|
4339
4250
|
protected onEnable?(): void;
|
|
4340
4251
|
/**
|
|
4341
|
-
*
|
|
4342
|
-
* 抽象方法:子类可实现禁用逻辑。
|
|
4252
|
+
* 生命周期钩子:工具 disable() 时调用
|
|
4343
4253
|
*/
|
|
4344
4254
|
protected onDisable?(): void;
|
|
4345
4255
|
/**
|
|
4346
|
-
*
|
|
4347
|
-
* 抽象方法:子类可实现移除逻辑。
|
|
4348
|
-
*/
|
|
4349
|
-
protected onRemove?(): void;
|
|
4350
|
-
/**
|
|
4351
|
-
* Bind events.
|
|
4352
|
-
* 绑定事件。
|
|
4256
|
+
* 内部:绑定 Map 事件
|
|
4353
4257
|
*/
|
|
4354
4258
|
private _bindEvents;
|
|
4355
4259
|
/**
|
|
4356
|
-
*
|
|
4357
|
-
* 解绑事件。
|
|
4260
|
+
* 内部:解绑 Map 事件
|
|
4358
4261
|
*/
|
|
4359
4262
|
private _unbindEvents;
|
|
4360
|
-
/**
|
|
4361
|
-
* Helper method: Register map event listener (Automatically managed, auto-removed on disable).
|
|
4362
|
-
* 辅助方法:注册地图事件监听(自动管理,disable 时自动移除)。
|
|
4363
|
-
*/
|
|
4364
|
-
protected addMapEvent(type: string, fn: (e: any) => void, context?: any): void;
|
|
4365
4263
|
}
|
|
4366
4264
|
|
|
4367
4265
|
declare const MapTool_base: {
|
|
@@ -4393,9 +4291,7 @@ declare const MapTool_base: {
|
|
|
4393
4291
|
} & typeof EmptyBase;
|
|
4394
4292
|
|
|
4395
4293
|
/**
|
|
4396
|
-
* MapTool configuration (Reserved for future extension)
|
|
4397
4294
|
* MapTool 配置项(预留,将来可以扩展)
|
|
4398
|
-
* @category Map
|
|
4399
4295
|
*/
|
|
4400
4296
|
declare type MapToolOptions = ClassOptions_2 & {};
|
|
4401
4297
|
|