my-openlayer 2.1.12 → 2.2.0
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/core/MapTools.d.ts +9 -0
- package/core/MapTools.js +24 -0
- package/core/Point.d.ts +10 -13
- package/core/Point.js +13 -54
- package/package.json +1 -1
package/core/MapTools.d.ts
CHANGED
|
@@ -62,6 +62,15 @@ export default class MapTools {
|
|
|
62
62
|
* @throws 当参数无效时抛出错误
|
|
63
63
|
*/
|
|
64
64
|
static setLayerVisible: (map: Map, layerName: string, visible: boolean) => void;
|
|
65
|
+
/**
|
|
66
|
+
* 地图定位
|
|
67
|
+
* @param lgtd 经度
|
|
68
|
+
* @param lttd 纬度
|
|
69
|
+
* @param zoom 缩放级别
|
|
70
|
+
* @param duration 动画时长
|
|
71
|
+
* @returns 定位是否成功
|
|
72
|
+
*/
|
|
73
|
+
locationAction(lgtd: number, lttd: number, zoom?: number, duration?: number): boolean;
|
|
65
74
|
/**
|
|
66
75
|
* 获取地图实例
|
|
67
76
|
* @returns 地图实例
|
package/core/MapTools.js
CHANGED
|
@@ -189,6 +189,30 @@ class MapTools {
|
|
|
189
189
|
throw new Error('Failed to set layer visibility');
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
+
/**
|
|
193
|
+
* 地图定位
|
|
194
|
+
* @param lgtd 经度
|
|
195
|
+
* @param lttd 纬度
|
|
196
|
+
* @param zoom 缩放级别
|
|
197
|
+
* @param duration 动画时长
|
|
198
|
+
* @returns 定位是否成功
|
|
199
|
+
*/
|
|
200
|
+
locationAction(lgtd, lttd, zoom = 20, duration = 3000) {
|
|
201
|
+
if (!this.map) {
|
|
202
|
+
throw new Error('Map instance is not available');
|
|
203
|
+
}
|
|
204
|
+
if (!ValidationUtils.validateLngLat(lgtd, lttd)) {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
this.map.getView().animate({ center: [lgtd, lttd], zoom, duration });
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
this.errorHandler.error('[地图定位]', '定位失败:', error);
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
192
216
|
/**
|
|
193
217
|
* 获取地图实例
|
|
194
218
|
* @returns 地图实例
|
package/core/Point.d.ts
CHANGED
|
@@ -60,23 +60,11 @@ export default class Point {
|
|
|
60
60
|
* @param twinkleList 闪烁点数据
|
|
61
61
|
* @param callback
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
addDomPoint(twinkleList: TwinkleItem[], callback?: Function): {
|
|
64
64
|
anchors: Overlay[];
|
|
65
65
|
remove: () => void;
|
|
66
66
|
setVisible: (visible: boolean) => void;
|
|
67
67
|
};
|
|
68
|
-
/**
|
|
69
|
-
* 地图定位
|
|
70
|
-
* @param lgtd 经度
|
|
71
|
-
* @param lttd 纬度
|
|
72
|
-
* @param zoom 缩放级别
|
|
73
|
-
* @param duration 动画时长
|
|
74
|
-
*/
|
|
75
|
-
locationAction(lgtd: number, lttd: number, zoom?: number, duration?: number): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* 设置dom元素为点位
|
|
78
|
-
*/
|
|
79
|
-
addDomPoint(id: string, lgtd: number, lttd: number): boolean;
|
|
80
68
|
/**
|
|
81
69
|
* 添加vue组件为点位
|
|
82
70
|
* @param pointDataList 点位信息列表
|
|
@@ -94,4 +82,13 @@ export default class Point {
|
|
|
94
82
|
remove: () => void;
|
|
95
83
|
getPoints: () => VueTemplatePointInstance[];
|
|
96
84
|
};
|
|
85
|
+
/**
|
|
86
|
+
* 地图定位
|
|
87
|
+
* @deprecated 请使用 MapTools.locationAction 方法代替
|
|
88
|
+
* @param lgtd 经度
|
|
89
|
+
* @param lttd 纬度
|
|
90
|
+
* @param zoom 缩放级别
|
|
91
|
+
* @param duration 动画时长
|
|
92
|
+
*/
|
|
93
|
+
locationAction(lgtd: number, lttd: number, zoom?: number, duration?: number): boolean;
|
|
97
94
|
}
|
package/core/Point.js
CHANGED
|
@@ -8,7 +8,7 @@ import VectorSource from "ol/source/Vector";
|
|
|
8
8
|
import { Cluster } from 'ol/source';
|
|
9
9
|
import VueTemplatePoint from './VueTemplatePoint';
|
|
10
10
|
import { ValidationUtils } from '../utils/ValidationUtils';
|
|
11
|
-
import
|
|
11
|
+
import MapTools from './MapTools';
|
|
12
12
|
export default class Point {
|
|
13
13
|
constructor(map) {
|
|
14
14
|
this.map = map;
|
|
@@ -246,7 +246,7 @@ export default class Point {
|
|
|
246
246
|
* @param twinkleList 闪烁点数据
|
|
247
247
|
* @param callback
|
|
248
248
|
*/
|
|
249
|
-
|
|
249
|
+
addDomPoint(twinkleList, callback) {
|
|
250
250
|
let anchors = [];
|
|
251
251
|
twinkleList.forEach(twinkleItem => {
|
|
252
252
|
// 创建DOM元素
|
|
@@ -293,58 +293,6 @@ export default class Point {
|
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
|
-
/**
|
|
297
|
-
* 地图定位
|
|
298
|
-
* @param lgtd 经度
|
|
299
|
-
* @param lttd 纬度
|
|
300
|
-
* @param zoom 缩放级别
|
|
301
|
-
* @param duration 动画时长
|
|
302
|
-
*/
|
|
303
|
-
locationAction(lgtd, lttd, zoom = 20, duration = 3000) {
|
|
304
|
-
if (!ValidationUtils.validateLngLat(lgtd, lttd)) {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
try {
|
|
308
|
-
this.map.getView().animate({ center: [lgtd, lttd], zoom, duration });
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
catch (error) {
|
|
312
|
-
ErrorHandler.getInstance().error('[地图定位]', '定位失败:', error);
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* 设置dom元素为点位
|
|
318
|
-
*/
|
|
319
|
-
addDomPoint(id, lgtd, lttd) {
|
|
320
|
-
if (!id) {
|
|
321
|
-
ErrorHandler.getInstance().error('Element ID is required');
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
if (!ValidationUtils.validateLngLat(lgtd, lttd)) {
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
const el = document.getElementById(id);
|
|
328
|
-
if (!el) {
|
|
329
|
-
ErrorHandler.getInstance().error(`Element with id '${id}' not found`);
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
try {
|
|
333
|
-
const anchor = new Overlay({
|
|
334
|
-
id: id,
|
|
335
|
-
element: el,
|
|
336
|
-
positioning: 'center-center',
|
|
337
|
-
stopEvent: false
|
|
338
|
-
});
|
|
339
|
-
anchor.setPosition([lgtd, lttd]);
|
|
340
|
-
this.map.addOverlay(anchor);
|
|
341
|
-
return true;
|
|
342
|
-
}
|
|
343
|
-
catch (error) {
|
|
344
|
-
ErrorHandler.getInstance().error('Failed to set DOM point:', error);
|
|
345
|
-
return false;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
296
|
/**
|
|
349
297
|
* 添加vue组件为点位
|
|
350
298
|
* @param pointDataList 点位信息列表
|
|
@@ -368,4 +316,15 @@ export default class Point {
|
|
|
368
316
|
throw new Error(`Failed to create Vue template points: ${error}`);
|
|
369
317
|
}
|
|
370
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* 地图定位
|
|
321
|
+
* @deprecated 请使用 MapTools.locationAction 方法代替
|
|
322
|
+
* @param lgtd 经度
|
|
323
|
+
* @param lttd 纬度
|
|
324
|
+
* @param zoom 缩放级别
|
|
325
|
+
* @param duration 动画时长
|
|
326
|
+
*/
|
|
327
|
+
locationAction(lgtd, lttd, zoom = 20, duration = 3000) {
|
|
328
|
+
return new MapTools(this.map).locationAction(lgtd, lttd, zoom, duration);
|
|
329
|
+
}
|
|
371
330
|
}
|