hn-map 1.0.10 → 1.1.1

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.
Files changed (45) hide show
  1. package/README.md +5 -22
  2. package/dist/index.js +2313 -610
  3. package/package.json +11 -8
  4. package/src/base/gaode_entity.ts +61 -0
  5. package/src/base/mars3d_entity.ts +64 -0
  6. package/src/base/siji_entity.ts +118 -0
  7. package/src/graphic/circle.ts +218 -0
  8. package/src/graphic/divPoint.ts +133 -0
  9. package/src/graphic/imagePoint.ts +237 -0
  10. package/src/graphic/label.ts +330 -0
  11. package/src/graphic/line.ts +345 -0
  12. package/src/graphic/numPoint.ts +290 -0
  13. package/src/graphic/point.ts +234 -0
  14. package/src/graphic/polygon.ts +188 -0
  15. package/src/graphic/rectangle.ts +202 -0
  16. package/src/index.ts +213 -0
  17. package/src/layer/cluster.ts +276 -0
  18. package/src/layer/geoJson.ts +174 -0
  19. package/src/layer/heatMap.ts +163 -0
  20. package/src/layer/layer.ts +464 -0
  21. package/src/layer/pointCloud.ts +78 -0
  22. package/src/map.ts +433 -0
  23. package/src/other/route.ts +457 -0
  24. package/src/types/globals.d.ts +5 -0
  25. package/src/util.ts +216 -0
  26. package/src/base/gaode_entity.js +0 -59
  27. package/src/base/mars3d_entity.js +0 -50
  28. package/src/graphic/circle.js +0 -159
  29. package/src/graphic/divPoint.js +0 -86
  30. package/src/graphic/imagePoint.js +0 -163
  31. package/src/graphic/label.js +0 -176
  32. package/src/graphic/line.js +0 -203
  33. package/src/graphic/numPoint.js +0 -119
  34. package/src/graphic/point.js +0 -144
  35. package/src/graphic/polygon.js +0 -111
  36. package/src/graphic/rectangle.js +0 -115
  37. package/src/index.js +0 -105
  38. package/src/layer/cluster.js +0 -277
  39. package/src/layer/geoJson.js +0 -174
  40. package/src/layer/heatMap.js +0 -163
  41. package/src/layer/layer.js +0 -311
  42. package/src/layer/pointCloud.js +0 -78
  43. package/src/map.js +0 -303
  44. package/src/other/route.js +0 -217
  45. package/src/util.js +0 -103
package/dist/index.js CHANGED
@@ -1,38 +1,21 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
3
  typeof define === 'function' && define.amd ? define(factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.hnMap = factory());
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.HnMap = factory());
5
5
  })(this, (function () { 'use strict';
6
6
 
7
+ function _arrayLikeToArray(r, a) {
8
+ (null == a || a > r.length) && (a = r.length);
9
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
10
+ return n;
11
+ }
12
+ function _arrayWithHoles(r) {
13
+ if (Array.isArray(r)) return r;
14
+ }
7
15
  function _assertThisInitialized(e) {
8
16
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9
17
  return e;
10
18
  }
11
- function asyncGeneratorStep(n, t, e, r, o, a, c) {
12
- try {
13
- var i = n[a](c),
14
- u = i.value;
15
- } catch (n) {
16
- return void e(n);
17
- }
18
- i.done ? t(u) : Promise.resolve(u).then(r, o);
19
- }
20
- function _asyncToGenerator(n) {
21
- return function () {
22
- var t = this,
23
- e = arguments;
24
- return new Promise(function (r, o) {
25
- var a = n.apply(t, e);
26
- function _next(n) {
27
- asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
28
- }
29
- function _throw(n) {
30
- asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
31
- }
32
- _next(void 0);
33
- });
34
- };
35
- }
36
19
  function _callSuper(t, o, e) {
37
20
  return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
38
21
  }
@@ -83,26 +66,35 @@
83
66
  return !!t;
84
67
  })();
85
68
  }
86
- function ownKeys(e, r) {
87
- var t = Object.keys(e);
88
- if (Object.getOwnPropertySymbols) {
89
- var o = Object.getOwnPropertySymbols(e);
90
- r && (o = o.filter(function (r) {
91
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
92
- })), t.push.apply(t, o);
69
+ function _iterableToArrayLimit(r, l) {
70
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
71
+ if (null != t) {
72
+ var e,
73
+ n,
74
+ i,
75
+ u,
76
+ a = [],
77
+ f = !0,
78
+ o = !1;
79
+ try {
80
+ if (i = (t = t.call(r)).next, 0 === l) {
81
+ if (Object(t) !== t) return;
82
+ f = !1;
83
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
84
+ } catch (r) {
85
+ o = !0, n = r;
86
+ } finally {
87
+ try {
88
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
89
+ } finally {
90
+ if (o) throw n;
91
+ }
92
+ }
93
+ return a;
93
94
  }
94
- return t;
95
95
  }
96
- function _objectSpread2(e) {
97
- for (var r = 1; r < arguments.length; r++) {
98
- var t = null != arguments[r] ? arguments[r] : {};
99
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
100
- _defineProperty(e, r, t[r]);
101
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
102
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
103
- });
104
- }
105
- return e;
96
+ function _nonIterableRest() {
97
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
106
98
  }
107
99
  function _possibleConstructorReturn(t, e) {
108
100
  if (e && ("object" == typeof e || "function" == typeof e)) return e;
@@ -224,6 +216,9 @@
224
216
  return t.__proto__ = e, t;
225
217
  }, _setPrototypeOf(t, e);
226
218
  }
219
+ function _slicedToArray(r, e) {
220
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
221
+ }
227
222
  function _toPrimitive(t, r) {
228
223
  if ("object" != typeof t || !t) return t;
229
224
  var e = t[Symbol.toPrimitive];
@@ -247,6 +242,43 @@
247
242
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
248
243
  }, _typeof(o);
249
244
  }
245
+ function _unsupportedIterableToArray(r, a) {
246
+ if (r) {
247
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
248
+ var t = {}.toString.call(r).slice(8, -1);
249
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
250
+ }
251
+ }
252
+
253
+ /******************************************************************************
254
+ Copyright (c) Microsoft Corporation.
255
+
256
+ Permission to use, copy, modify, and/or distribute this software for any
257
+ purpose with or without fee is hereby granted.
258
+
259
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
260
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
261
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
262
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
263
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
264
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
265
+ PERFORMANCE OF THIS SOFTWARE.
266
+ ***************************************************************************** */
267
+
268
+ function __awaiter(thisArg, _arguments, P, generator) {
269
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
270
+ return new (P || (P = Promise))(function (resolve, reject) {
271
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
272
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
273
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
274
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
275
+ });
276
+ }
277
+
278
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
279
+ var e = new Error(message);
280
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
281
+ };
250
282
 
251
283
  // import Vue from 'vue'
252
284
  //
@@ -262,7 +294,6 @@
262
294
  // })
263
295
  // return app.$el
264
296
  // }
265
-
266
297
  // 对象深度合并
267
298
  function deepMerge(target, source) {
268
299
  for (var _i = 0, _Object$keys = Object.keys(source); _i < _Object$keys.length; _i++) {
@@ -276,7 +307,6 @@
276
307
  }
277
308
  return target;
278
309
  }
279
-
280
310
  // 递归格式化高德坐标系
281
311
  function wgs84ToGcj02Format(position) {
282
312
  // 判断是否是数组
@@ -287,11 +317,11 @@
287
317
  return wgs84ToGcj02Format(item);
288
318
  });
289
319
  } else if (position.every(function (item) {
290
- return _typeof(item) === 'object';
320
+ return _typeof(item) === "object";
291
321
  })) {
292
322
  return position.map(function (item) {
293
323
  var data = wgs84ToGcj02Format([item.lng, item.lat]);
294
- return _objectSpread2(_objectSpread2({}, item), {}, {
324
+ return Object.assign(Object.assign({}, item), {
295
325
  lng: data[0],
296
326
  lat: data[1]
297
327
  });
@@ -300,12 +330,11 @@
300
330
  return wgs84ToGcj02(position[0], position[1]);
301
331
  }
302
332
  }
303
-
304
- /**
305
- * WGS-84 转 GCJ-02(高德坐标)
306
- * @param {number} wgsLat - WGS-84纬度
307
- * @param {number} wgsLng - WGS-84经度
308
- * @returns {[number, number]} GCJ-02经纬度数组
333
+ /**
334
+ * WGS-84 转 GCJ-02(高德坐标)
335
+ * @param {number} wgsLat - WGS-84纬度
336
+ * @param {number} wgsLng - WGS-84经度
337
+ * @returns {[number, number]} GCJ-02经纬度数组
309
338
  */
310
339
  function wgs84ToGcj02(wgsLng, wgsLat) {
311
340
  if (!isCorrectPosition(wgsLng, wgsLat)) {
@@ -313,7 +342,6 @@
313
342
  }
314
343
  var a = 6378245.0; // 长半轴
315
344
  var ee = 0.00669342162296594323; // 扁率
316
-
317
345
  function transformLat(x, y) {
318
346
  var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
319
347
  ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
@@ -338,16 +366,82 @@
338
366
  var gcjLng = wgsLng + dLng;
339
367
  return [gcjLng, gcjLat];
340
368
  }
341
-
342
- /**
343
- * 判断是否为正确的坐标
344
- * @param {number} lat - 纬度
345
- * @param {number} lng - 经度
346
- * @returns {boolean}
347
- */
369
+ /**
370
+ * 判断是否为正确的坐标
371
+ * @param {number} lat - 纬度
372
+ * @param {number} lng - 经度
373
+ * @returns {boolean}
374
+ */
348
375
  function isCorrectPosition(lng, lat) {
349
376
  return lng <= 180 && lng >= -180 && lat <= 90 && lat >= -90;
350
377
  }
378
+ // 根据矩形左上角和右上角坐标计算矩形坐标对
379
+ function createRectangleCoordinates(leftTop, rightBottom) {
380
+ var _leftTop = _slicedToArray(leftTop, 2),
381
+ leftTopLng = _leftTop[0],
382
+ leftTopLat = _leftTop[1];
383
+ var _rightBottom = _slicedToArray(rightBottom, 2),
384
+ rightBottomLng = _rightBottom[0],
385
+ rightBottomLat = _rightBottom[1];
386
+ // 计算四个角点
387
+ var leftTopPoint = [Number(leftTopLng), Number(leftTopLat)];
388
+ var rightTopPoint = [Number(rightBottomLng), Number(leftTopLat)];
389
+ var rightBottomPoint = [Number(rightBottomLng), Number(rightBottomLat)];
390
+ var leftBottomPoint = [Number(leftTopLng), Number(rightBottomLat)];
391
+ // 返回五个点的坐标对(首尾相同)
392
+ return [leftTopPoint, rightTopPoint, rightBottomPoint, leftBottomPoint, leftTopPoint // 闭合矩形
393
+ ];
394
+ }
395
+ function getMapRangeHeightByLevel(level) {
396
+ // 输入校验:限制在 1~18
397
+ level = Math.max(1, Math.min(18, Math.floor(level)));
398
+ // 计算指定 level 对应的高度(level >= 2 时使用指数衰减)
399
+ function getHeight(lvl) {
400
+ if (lvl === 1) {
401
+ return Infinity; // level=1 表示“最大高度”,逻辑上为无穷大
402
+ } else {
403
+ return 32000000 / Math.pow(2, lvl - 2);
404
+ }
405
+ }
406
+ var endHeight = getHeight(level); // 当前 level 的“粗略”高度
407
+ var startHeight = level < 18 ? getHeight(level + 1) : 0; // 下一级更细
408
+ return {
409
+ startHeight: startHeight,
410
+ endHeight: endHeight
411
+ };
412
+ }
413
+ /**
414
+ * 根据 level 返回该层级的“中间高度”(几何平均值)
415
+ *
416
+ * @param {number} level - 缩放级别 [1, 18]
417
+ * @returns {number} 中间高度(米)
418
+ */
419
+ function getLevelMiddleHeight(level) {
420
+ var _getMapRangeHeightByL = getMapRangeHeightByLevel(level),
421
+ startHeight = _getMapRangeHeightByL.startHeight,
422
+ endHeight = _getMapRangeHeightByL.endHeight;
423
+ // 如果 startHeight 为 0(如 level=18),几何平均会为 0,不合理
424
+ // 所以 level=18 特殊处理:返回 (0 + end)/2 或直接返回 end * 0.7 左右
425
+ if (startHeight === 0) {
426
+ return endHeight * 0.7; // 经验值,贴近“中间感知”
427
+ }
428
+ // 几何平均:√(start × end)
429
+ return Math.sqrt(startHeight * endHeight);
430
+ }
431
+ /**
432
+ * 根据高度反推 level(1~18)
433
+ * @param {number} height - 当前视野高度(米)
434
+ * @returns {number} level
435
+ */
436
+ function getHeightToLevel(height) {
437
+ if (height > 32000000) return 1;
438
+ if (height <= 0) return 18;
439
+ // 解公式:height = 32e6 / 2^(level-2)
440
+ var level = 2 + Math.log(32000000 / height) / Math.log(2);
441
+ level = Math.floor(level);
442
+ // 限制在 1~18
443
+ return Math.max(1, Math.min(18, level));
444
+ }
351
445
 
352
446
  var map = (function (hnMap) {
353
447
  var defaultOption = {
@@ -357,39 +451,46 @@
357
451
  lng: 112.55074,
358
452
  // 缩放级别
359
453
  level: 11,
360
- // 高度
361
- alt: 30000,
362
454
  // 旋转角度
363
455
  heading: 0,
364
456
  // 俯仰角度
365
- pitch: -45,
457
+ pitch: -60,
366
458
  // 翻滚角度
367
459
  roll: 0,
368
- mars3d_config: '',
460
+ mars3d_config: "",
369
461
  // 高德地图key
370
- gaode_key: '',
462
+ gaode_key: "",
371
463
  // 思极key
372
- sj_app_key: '',
373
- sj_app_secret: ''
464
+ sj_app_key: "",
465
+ sj_app_secret: "",
466
+ style: "aegis://styles/aegis/Streets-Raster512"
374
467
  };
375
468
  var mars3d_map = /*#__PURE__*/function () {
376
469
  function mars3d_map(id, option) {
470
+ var _this = this;
377
471
  _classCallCheck(this, mars3d_map);
378
- _defineProperty(this, "map", null);
379
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
380
- _defineProperty(this, "config", null);
472
+ this.map = null;
473
+ this.option = JSON.parse(JSON.stringify(defaultOption));
474
+ this.config = null;
381
475
  // 图层集合
382
- _defineProperty(this, "layerList", []);
383
- _defineProperty(this, "event", {});
384
476
  this.layerList = [];
477
+ this.event = {};
478
+ this.level = null;
479
+ this.layerList = [];
480
+ this.level = this.option.level;
385
481
  deepMerge(this.option, option);
386
482
  this.config = this.formatConfig(this.option);
387
483
  this.map = new mars3d.Map(id, this.config);
484
+ this.map.on("cameraMoveEnd", function (e) {
485
+ var height = _this.map.getCameraView().alt;
486
+ _this.level = getHeightToLevel(height);
487
+ });
388
488
  }
389
489
  return _createClass(mars3d_map, [{
390
490
  key: "formatConfig",
391
491
  value: function formatConfig(option) {
392
- return _objectSpread2(_objectSpread2({}, option.mars3d_config), {}, {
492
+ var alt = getLevelMiddleHeight(option.level);
493
+ return Object.assign(Object.assign({}, option.mars3d_config), {
393
494
  control: {
394
495
  locationBar: {
395
496
  fps: true
@@ -399,7 +500,7 @@
399
500
  center: {
400
501
  lat: option.lat,
401
502
  lng: option.lng,
402
- alt: option.alt,
503
+ alt: alt,
403
504
  heading: 360 - option.heading || 0,
404
505
  pitch: option.pitch || 0,
405
506
  roll: option.roll || 0
@@ -415,7 +516,7 @@
415
516
  if (this.layerList.find(function (v) {
416
517
  return v.id === layer.id;
417
518
  })) {
418
- console.error('已存在同名图层' + layer.id);
519
+ console.error("已存在同名图层" + layer.id);
419
520
  } else {
420
521
  this.layerList.push(layer);
421
522
  this.map.addLayer(layer.layerEntity);
@@ -429,6 +530,7 @@
429
530
  return v.id === layerId;
430
531
  });
431
532
  }
533
+ // 删除图层
432
534
  }, {
433
535
  key: "removeLayer",
434
536
  value: function removeLayer(layerId) {
@@ -440,6 +542,7 @@
440
542
  layer.destroy();
441
543
  }
442
544
  }
545
+ // 清空图层
443
546
  }, {
444
547
  key: "clearLayer",
445
548
  value: function clearLayer(layerId) {
@@ -454,7 +557,7 @@
454
557
  value: function on(eventType, callback) {
455
558
  this.off(eventType);
456
559
  switch (eventType) {
457
- case 'click':
560
+ case "click":
458
561
  this.event[eventType] = function (event) {
459
562
  var point = mars3d.LngLatPoint.fromCartesian(event.cartesian); //转为经纬度
460
563
  point.format(); // 经度、纬度、高度
@@ -466,7 +569,7 @@
466
569
  callback(position);
467
570
  };
468
571
  break;
469
- case 'cameraMoveEnd':
572
+ case "cameraMoveEnd":
470
573
  this.event[eventType] = function (event) {
471
574
  callback(event);
472
575
  };
@@ -482,22 +585,20 @@
482
585
  delete this.event[eventType];
483
586
  }
484
587
  }
485
-
486
- /**
487
- * 获取当前视口的经纬度范围
488
- * 返回参数 {xmin,xmax,ymin,ymax}
489
- * @returns {*}
588
+ /**
589
+ * 获取当前视口的经纬度范围
590
+ * 返回参数 {xmin,xmax,ymin,ymax}
591
+ * @returns {*}
490
592
  */
491
593
  }, {
492
594
  key: "getExtent",
493
595
  value: function getExtent() {
494
596
  return this.map.getExtent();
495
597
  }
496
-
497
- /**
498
- * 获取当前视高
499
- * 返回参数 {alt}
500
- * @returns {any}
598
+ /**
599
+ * 获取当前视高
600
+ * 返回参数 {alt}
601
+ * @returns {any}
501
602
  */
502
603
  }, {
503
604
  key: "getCameraView",
@@ -515,29 +616,45 @@
515
616
  value: function closePopup() {
516
617
  this.map.closePopup();
517
618
  }
518
-
519
619
  // 设置投影模式 2d/3d
520
620
  }, {
521
621
  key: "setMode",
522
622
  value: function setMode(mode) {
523
623
  var obj = {
524
- '2d': Cesium.SceneMode.SCENE2D,
525
- '3d': Cesium.SceneMode.SCENE3D
624
+ "2d": Cesium.SceneMode.SCENE2D,
625
+ "3d": Cesium.SceneMode.SCENE3D
526
626
  };
527
627
  this.map.scene.mode = obj[mode.toLowerCase()];
528
628
  }
629
+ }], [{
630
+ key: "create",
631
+ value: function create(id, option) {
632
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
633
+ var instance;
634
+ return _regenerator().w(function (_context) {
635
+ while (1) switch (_context.n) {
636
+ case 0:
637
+ instance = new mars3d_map(id, option); // 返回一个 Promise,等待地图的 'load' 事件
638
+ _context.n = 1;
639
+ return new Promise(function (resolve) {
640
+ resolve();
641
+ });
642
+ case 1:
643
+ return _context.a(2, instance);
644
+ }
645
+ }, _callee);
646
+ }));
647
+ }
529
648
  }]);
530
649
  }();
531
- // 允许构造函数
532
- _defineProperty(mars3d_map, "allowConstruction", false);
533
650
  var gaode_map = /*#__PURE__*/function () {
534
651
  function gaode_map(id, option) {
535
652
  _classCallCheck(this, gaode_map);
536
- _defineProperty(this, "map", null);
537
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
538
- _defineProperty(this, "config", null);
653
+ this.map = null;
654
+ this.option = JSON.parse(JSON.stringify(defaultOption));
655
+ this.config = null;
539
656
  // 图层集合
540
- _defineProperty(this, "layerList", []);
657
+ this.layerList = [];
541
658
  this.layerList = [];
542
659
  deepMerge(this.option, option);
543
660
  this.config = this.formatConfig(this.option);
@@ -549,7 +666,7 @@
549
666
  return {
550
667
  viewMode: "2D",
551
668
  // 是否为3D地图模式
552
- zoom: option.level,
669
+ level: option.level,
553
670
  // 初始化地图级别
554
671
  pitch: option.pitch,
555
672
  rotation: option.heading,
@@ -566,7 +683,7 @@
566
683
  if (this.layerList.find(function (v) {
567
684
  return v.id === layer.id;
568
685
  })) {
569
- console.error('已存在同名图层');
686
+ console.error("已存在同名图层");
570
687
  } else {
571
688
  this.layerList.push(layer);
572
689
  this.map.add(layer.layerEntity);
@@ -600,33 +717,61 @@
600
717
  layer.clearEntity();
601
718
  }
602
719
  }
720
+ }], [{
721
+ key: "create",
722
+ value: function create(id, option) {
723
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
724
+ var instance;
725
+ return _regenerator().w(function (_context2) {
726
+ while (1) switch (_context2.n) {
727
+ case 0:
728
+ instance = new gaode_map(id, option); // 返回一个 Promise,等待地图的 'load' 事件
729
+ _context2.n = 1;
730
+ return new Promise(function (resolve) {
731
+ resolve();
732
+ });
733
+ case 1:
734
+ return _context2.a(2, instance);
735
+ }
736
+ }, _callee2);
737
+ }));
738
+ }
603
739
  }]);
604
740
  }();
605
741
  var siji_map = /*#__PURE__*/function () {
606
742
  function siji_map(id, option) {
607
- var _this = this;
743
+ var _this2 = this;
608
744
  _classCallCheck(this, siji_map);
609
- _defineProperty(this, "id", null);
610
- _defineProperty(this, "map", null);
611
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
612
- _defineProperty(this, "config", null);
745
+ this.id = null;
746
+ this.map = null;
747
+ this.option = JSON.parse(JSON.stringify(defaultOption));
748
+ this.config = null;
613
749
  // 图层集合
614
- _defineProperty(this, "layerList", []);
615
- _defineProperty(this, "event", {});
750
+ this.layerList = [];
751
+ this.event = {};
752
+ this.level = null;
616
753
  this.id = id;
617
754
  this.layerList = [];
755
+ this.level = this.option.level;
618
756
  deepMerge(this.option, option);
619
757
  this.config = this.formatConfig(this.option);
620
- SGMap.tokenTask.login(option.sj_app_key, option.sj_app_secret).then(function (res) {
621
- _this.map = new SGMap.Map(_this.config);
622
- });
758
+ this.map = new SGMap.Map(this.config);
759
+ this.map.on("moveend", function (e) {
760
+ return _this2.updateMapParams(e);
761
+ }); // 地图移动完成
762
+ this.map.on("zoomend", function (e) {
763
+ return _this2.updateMapParams(e);
764
+ }); // 地图缩放完成
765
+ this.map.on("pitchend", function (e) {
766
+ return _this2.updateMapParams(e);
767
+ }); // 地图俯仰角度完成
623
768
  }
624
769
  return _createClass(siji_map, [{
625
770
  key: "formatConfig",
626
771
  value: function formatConfig(option) {
627
772
  return {
628
773
  container: this.id,
629
- style: "aegis://styles/aegis/Streets-Raster512",
774
+ style: "aegis://styles/aegis/Streets-v2",
630
775
  // 默认缩放层级
631
776
  zoom: option.level,
632
777
  // 地图中心点
@@ -641,11 +786,13 @@
641
786
  if (this.layerList.find(function (v) {
642
787
  return v.id === layer.id;
643
788
  })) {
644
- console.error('已存在同名图层');
789
+ console.error("已存在同名图层");
645
790
  } else {
646
- this.layerList.push(layer);
647
- this.map.map.addLayer(layer.layerEntity);
648
- return layer;
791
+ if (this.map) {
792
+ this.layerList.push(layer);
793
+ // this.map.addLayer(layer.config);
794
+ return layer;
795
+ }
649
796
  }
650
797
  }
651
798
  }, {
@@ -659,11 +806,11 @@
659
806
  key: "removeLayer",
660
807
  value: function removeLayer(layerId) {
661
808
  var layer = this.getLayer(layerId);
662
- if (layer) {
663
- layer.destroy();
809
+ if (layer.id) {
664
810
  this.layerList = this.layerList.filter(function (v) {
665
811
  return v.id !== layerId;
666
812
  });
813
+ layer.destroy();
667
814
  }
668
815
  }
669
816
  }, {
@@ -675,6 +822,123 @@
675
822
  layer.clearEntity();
676
823
  }
677
824
  }
825
+ }, {
826
+ key: "getExtent",
827
+ value: function getExtent() {
828
+ var data = this.map.getBounds();
829
+ return {
830
+ xmin: data._sw.lng,
831
+ ymin: data._sw.lat,
832
+ xmax: data._ne.lng,
833
+ ymax: data._ne.lat
834
+ };
835
+ }
836
+ }, {
837
+ key: "on",
838
+ value: function on(eventType, callback) {
839
+ var _this3 = this;
840
+ this.off(eventType);
841
+ switch (eventType) {
842
+ case "click":
843
+ this.event[eventType] = function (event) {
844
+ callback(event.lngLat);
845
+ };
846
+ break;
847
+ case "dblclick":
848
+ this.event[eventType] = function (event) {
849
+ callback(event);
850
+ };
851
+ break;
852
+ case "cameraMoveEnd":
853
+ this.event[eventType] = function () {
854
+ _this3.map.on("moveend", function (event) {
855
+ return callback(event);
856
+ }); // 地图移动完成
857
+ _this3.map.on("zoomend", function (event) {
858
+ return callback(event);
859
+ }); // 地图缩放完成
860
+ _this3.map.on("pitchend", function (event) {
861
+ return callback(event);
862
+ }); // 地图俯仰角度完成
863
+ };
864
+ this.event[eventType]();
865
+ break;
866
+ //镜头移动事件
867
+ case "moveend":
868
+ this.event[eventType] = function (event) {
869
+ callback(event);
870
+ };
871
+ break;
872
+ case "zoomend":
873
+ //"levelend"
874
+ this.event[eventType] = function (event) {
875
+ callback(event);
876
+ };
877
+ break;
878
+ case "mouseenter":
879
+ this.event[eventType] = function (event) {
880
+ callback(event);
881
+ };
882
+ break;
883
+ case "mouseleave":
884
+ this.event[eventType] = function (event) {
885
+ callback(event);
886
+ };
887
+ break;
888
+ case "mousemove":
889
+ this.event[eventType] = function (event) {
890
+ callback(event);
891
+ };
892
+ break;
893
+ }
894
+ this.map.on(eventType, this.event[eventType]);
895
+ }
896
+ }, {
897
+ key: "off",
898
+ value: function off(eventType) {
899
+ if (this.event[eventType]) {
900
+ this.map.off(eventType, this.event[eventType]);
901
+ delete this.event[eventType];
902
+ }
903
+ }
904
+ // 更新当前地图参数
905
+ }, {
906
+ key: "updateMapParams",
907
+ value: function updateMapParams(e) {
908
+ this.level = this.map.getZoom();
909
+ var viewPos = this.getExtent();
910
+ console.log("当前缩放级别level:", this.level);
911
+ if (this.level !== this.option.level) {
912
+ this.layerList.forEach(function (layer) {
913
+ layer.children.forEach(function (entity) {
914
+ entity.option.distanceDisplayCondition && layer.updateEntity(entity, viewPos);
915
+ });
916
+ });
917
+ } else {
918
+ return;
919
+ }
920
+ }
921
+ }], [{
922
+ key: "create",
923
+ value: function create(id, option) {
924
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee3() {
925
+ var instance;
926
+ return _regenerator().w(function (_context3) {
927
+ while (1) switch (_context3.n) {
928
+ case 0:
929
+ instance = new siji_map(id, option); // 返回一个 Promise,等待地图的 'load' 事件
930
+ _context3.n = 1;
931
+ return new Promise(function (resolve) {
932
+ instance.map.on("load", function (e) {
933
+ resolve(e);
934
+ });
935
+ });
936
+ case 1:
937
+ return _context3.a(2, instance);
938
+ }
939
+ }, _callee3);
940
+ }));
941
+ }
678
942
  }]);
679
943
  }();
680
944
  var map = {
@@ -690,17 +954,17 @@
690
954
  var mars3d_class = /*#__PURE__*/function () {
691
955
  function mars3d_class(option) {
692
956
  _classCallCheck(this, mars3d_class);
693
- _defineProperty(this, "type", 'layer');
694
- _defineProperty(this, "id", null);
695
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
696
- _defineProperty(this, "config", null);
697
- _defineProperty(this, "children", null);
698
- _defineProperty(this, "layerEntity", null);
957
+ this.type = "layer";
958
+ this.id = null;
959
+ this.option = JSON.parse(JSON.stringify(defaultOption));
960
+ this.config = null;
961
+ this.children = null;
962
+ this.layerEntity = null;
699
963
  this.id = option.id;
700
964
  this.children = [];
701
965
  deepMerge(this.option, option);
702
966
  this.config = this.formatConfig(this.option);
703
- this.layerEntity = new mars3d.layer.GraphicLayer(this.config);
967
+ this.layerEntity = new mars3d.layer.GraphicLayer(this.config); // 创建图层
704
968
  }
705
969
  return _createClass(mars3d_class, [{
706
970
  key: "formatConfig",
@@ -723,7 +987,10 @@
723
987
  console.error("已存在同名图形" + entity.id);
724
988
  } else {
725
989
  this.children.push(entity);
726
- this.layerEntity.addGraphic(entity.graphic);
990
+ this.layerEntity.addGraphic(entity.graphic); // 添加图形
991
+ if (entity.type == "route") {
992
+ entity.start();
993
+ }
727
994
  }
728
995
  }
729
996
  }, {
@@ -731,9 +998,6 @@
731
998
  value: function removeEntity(entityParam) {
732
999
  var entity = this.getEntity(entityParam);
733
1000
  if (entity) {
734
- this.children = this.children.filter(function (v) {
735
- return v.id !== entity.id;
736
- });
737
1001
  this.layerEntity.removeGraphic(entity.graphic);
738
1002
  }
739
1003
  }
@@ -771,10 +1035,9 @@
771
1035
  value: function flyTo() {
772
1036
  this.layerEntity.flyTo();
773
1037
  }
774
-
775
- /**
776
- * 飞向指定的多个图形
777
- * @param entities
1038
+ /**
1039
+ * 飞向指定的多个图形
1040
+ * @param entities
778
1041
  */
779
1042
  }, {
780
1043
  key: "flyToCustomEntities",
@@ -795,7 +1058,6 @@
795
1058
  maxLat = Math.max(maxLat, lat);
796
1059
  });
797
1060
  });
798
-
799
1061
  // 飞到这个矩形范围
800
1062
  hnMap.map.map.flyToExtent({
801
1063
  xmin: minLon,
@@ -804,12 +1066,12 @@
804
1066
  ymax: maxLat
805
1067
  });
806
1068
  }
807
-
808
1069
  // 添加属性弹窗
809
1070
  }, {
810
1071
  key: "addPopupByAttr",
811
1072
  value: function addPopupByAttr() {
812
1073
  this.layerEntity.bindPopup(function (event) {
1074
+ console.log(event.graphic, "====event.graphic==");
813
1075
  if (event.graphic.attr) {
814
1076
  var data = event.graphic.attr;
815
1077
  return mars3d.Util.getTemplateHtml({
@@ -820,13 +1082,16 @@
820
1082
  }
821
1083
  });
822
1084
  }
823
-
824
1085
  // 添加自定义dom弹窗
825
1086
  }, {
826
1087
  key: "addCustomPopup",
827
1088
  value: function addCustomPopup(getCustomDom) {
828
- this.layerEntity.bindPopup(/*#__PURE__*/function () {
829
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
1089
+ var _this2 = this;
1090
+ var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1091
+ offsetY: -20
1092
+ };
1093
+ this.layerEntity.bindPopup(function (event) {
1094
+ return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
830
1095
  var data, dom;
831
1096
  return _regenerator().w(function (_context) {
832
1097
  while (1) switch (_context.n) {
@@ -852,32 +1117,27 @@
852
1117
  }
853
1118
  }, _callee);
854
1119
  }));
855
- return function (_x) {
856
- return _ref.apply(this, arguments);
857
- };
858
- }(), {
859
- offsetY: -20
860
- });
1120
+ }, option);
861
1121
  }
862
1122
  }]);
863
1123
  }();
864
1124
  var gaode_class = /*#__PURE__*/function () {
865
1125
  function gaode_class(option) {
866
1126
  _classCallCheck(this, gaode_class);
867
- _defineProperty(this, "id", null);
868
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
869
- _defineProperty(this, "config", null);
870
- _defineProperty(this, "children", null);
871
- _defineProperty(this, "layerEntity", null);
1127
+ this.id = null;
1128
+ this.option = JSON.parse(JSON.stringify(defaultOption));
1129
+ this.config = null;
1130
+ this.children = null;
1131
+ this.layerEntity = null;
872
1132
  // 创建全局信息窗口实例
873
- _defineProperty(this, "propsInfoWindow", null);
874
- _defineProperty(this, "customInfoWindow", null);
875
- _defineProperty(this, "getCustomDom", null);
1133
+ this.propsInfoWindow = null;
1134
+ this.customInfoWindow = null;
1135
+ this.getCustomDom = null;
876
1136
  this.id = option.id;
877
1137
  this.children = [];
878
1138
  deepMerge(this.option, option);
879
1139
  this.config = this.formatConfig(this.option);
880
- this.layerEntity = new AMap.OverlayGroup([]);
1140
+ this.layerEntity = new AMap.OverlayGroup([]); // 创建图层
881
1141
  this.layerEntity.id = option.id;
882
1142
  }
883
1143
  return _createClass(gaode_class, [{
@@ -901,15 +1161,12 @@
901
1161
  console.error("已存在同名图形" + entity.id);
902
1162
  } else {
903
1163
  this.children.push(entity);
904
- this.layerEntity.addOverlay(entity.graphic);
905
-
1164
+ this.layerEntity.addOverlay(entity.graphic); // 添加图形
906
1165
  // 图层添加新图形后,需要重新调用绑定点击弹窗方法
907
1166
  if (this.propsInfoWindow) {
908
1167
  this.addPopupByAttr();
909
1168
  }
910
- if (this.customInfoWindow) {
911
- this.addCustomPopup();
912
- }
1169
+ if (this.customInfoWindow) ;
913
1170
  }
914
1171
  }
915
1172
  }, {
@@ -933,19 +1190,18 @@
933
1190
  }, {
934
1191
  key: "destroy",
935
1192
  value: function destroy() {
936
- var _this2 = this;
1193
+ var _this3 = this;
937
1194
  this.clearEntity();
938
1195
  hnMap.map.map.remove(this.layerEntity);
939
1196
  hnMap.map.layerList = hnMap.map.layerList.filter(function (v) {
940
- return v.id !== _this2.id;
1197
+ return v.id !== _this3.id;
941
1198
  });
942
1199
  }
943
-
944
1200
  // 添加属性弹窗
945
1201
  }, {
946
1202
  key: "addPopupByAttr",
947
1203
  value: function addPopupByAttr() {
948
- var _this3 = this;
1204
+ var _this4 = this;
949
1205
  if (!this.propsInfoWindow) {
950
1206
  this.propsInfoWindow = new AMap.InfoWindow({
951
1207
  offset: new AMap.Pixel(0, -30)
@@ -954,22 +1210,21 @@
954
1210
  var handleClick = function handleClick(e) {
955
1211
  var overlay = e.target; // 获取被点击的具体覆盖物
956
1212
  var data = overlay.getOptions().extData.data;
957
- var content = '';
1213
+ var content = "";
958
1214
  for (var key in data) {
959
1215
  content += "<div>".concat(key, ": ").concat(data[key], "</div>");
960
1216
  }
961
- _this3.propsInfoWindow.setContent(content);
962
- _this3.propsInfoWindow.open(hnMap.map.map, e.lnglat);
1217
+ _this4.propsInfoWindow.setContent(content);
1218
+ _this4.propsInfoWindow.open(hnMap.map.map, e.lnglat);
963
1219
  };
964
- this.layerEntity.off('click', handleClick);
965
- this.layerEntity.on('click', handleClick);
1220
+ this.layerEntity.off("click", handleClick);
1221
+ this.layerEntity.on("click", handleClick);
966
1222
  }
967
-
968
1223
  // 添加自定义dom弹窗
969
1224
  }, {
970
1225
  key: "addCustomPopup",
971
1226
  value: function addCustomPopup(getCustomDom) {
972
- var _this4 = this;
1227
+ var _this5 = this;
973
1228
  if (!this.customInfoWindow) {
974
1229
  this.customInfoWindow = new AMap.InfoWindow({
975
1230
  offset: new AMap.Pixel(0, -30)
@@ -981,25 +1236,29 @@
981
1236
  var handleClick = function handleClick(e) {
982
1237
  var overlay = e.target; // 获取被点击的具体覆盖物
983
1238
  var data = overlay.getOptions().extData.data;
984
- var dom = _this4.getCustomDom(data);
985
- _this4.customInfoWindow.setContent(dom);
986
- _this4.customInfoWindow.open(hnMap.map.map, e.lnglat);
1239
+ var dom = _this5.getCustomDom(data);
1240
+ _this5.customInfoWindow.setContent(dom);
1241
+ _this5.customInfoWindow.open(hnMap.map.map, e.lnglat);
987
1242
  };
988
- this.layerEntity.off('click', handleClick);
989
- this.layerEntity.on('click', handleClick);
1243
+ this.layerEntity.off("click", handleClick);
1244
+ this.layerEntity.on("click", handleClick);
990
1245
  }
991
1246
  }]);
992
1247
  }();
993
1248
  var siji_class = /*#__PURE__*/function () {
994
1249
  function siji_class(option) {
995
1250
  _classCallCheck(this, siji_class);
996
- _defineProperty(this, "id", null);
997
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
998
- _defineProperty(this, "config", null);
999
- _defineProperty(this, "children", null);
1000
- _defineProperty(this, "layerEntity", null);
1251
+ this.id = null;
1252
+ this.option = JSON.parse(JSON.stringify(defaultOption));
1253
+ this.config = null;
1254
+ this.children = null;
1255
+ this.hideChildrenMap = null;
1256
+ this.layerEntity = null;
1257
+ this.infoWindow = null;
1258
+ this.entity = null;
1001
1259
  this.id = option.id;
1002
1260
  this.children = [];
1261
+ this.hideChildrenMap = {};
1003
1262
  deepMerge(this.option, option);
1004
1263
  this.config = this.formatConfig(this.option);
1005
1264
  }
@@ -1008,6 +1267,26 @@
1008
1267
  value: function formatConfig(option) {
1009
1268
  return option;
1010
1269
  }
1270
+ }, {
1271
+ key: "updateEntity",
1272
+ value: function updateEntity(entity, viewPos) {
1273
+ var isUpdateEntity = hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) && hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
1274
+ if (isUpdateEntity) {
1275
+ if (!entity.show && this.isIncludesLabel(entity.option.position, viewPos)) {
1276
+ this.addLevelEntity(entity);
1277
+ }
1278
+ } else {
1279
+ if (entity.show) {
1280
+ this.removeLevelEntity(entity);
1281
+ }
1282
+ }
1283
+ }
1284
+ // 判断坐标是否在视口范围内
1285
+ }, {
1286
+ key: "isIncludesLabel",
1287
+ value: function isIncludesLabel(p, viewPos) {
1288
+ return p[0] > viewPos.xmin && p[0] < viewPos.xmax && p[1] > viewPos.ymin && p[1] < viewPos.ymax;
1289
+ }
1011
1290
  }, {
1012
1291
  key: "getEntity",
1013
1292
  value: function getEntity(id) {
@@ -1024,7 +1303,10 @@
1024
1303
  console.error("已存在同名图形" + entity.id);
1025
1304
  } else {
1026
1305
  this.children.push(entity);
1027
- hnMap.map.map.addLayer(entity.graphic);
1306
+ var isUpdateEntity = hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) && hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
1307
+ if (!entity.option.distanceDisplayCondition || isUpdateEntity) {
1308
+ this.addLevelEntity(entity);
1309
+ }
1028
1310
  }
1029
1311
  }
1030
1312
  }, {
@@ -1035,35 +1317,147 @@
1035
1317
  this.children = this.children.filter(function (v) {
1036
1318
  return v.id !== entity.id;
1037
1319
  });
1038
- this.layerEntity.removeOverlay(entity.graphic);
1039
- entity.destroy();
1320
+ this.removeLevelEntity(entity);
1321
+ }
1322
+ }
1323
+ }, {
1324
+ key: "addLevelEntity",
1325
+ value: function addLevelEntity(entity) {
1326
+ if (entity.type == "imagePoint") {
1327
+ hnMap.map.map.loadImage(entity.option.image, function (error, image) {
1328
+ hnMap.map.map.addImage(entity.id + "_image", image);
1329
+ hnMap.map.map.addLayer(entity.config);
1330
+ });
1331
+ } else if (entity.type == "numPoint") {
1332
+ hnMap.map.map.addLayer(entity.config);
1333
+ hnMap.map.map.addLayer(entity.configLabel);
1334
+ } else if (entity.type == "divPoint") {
1335
+ entity.graphic.setLngLat(entity.option.position).addTo(hnMap.map.map);
1336
+ } else if (entity.type == "circle") {
1337
+ var featureArr = {
1338
+ type: "Feature",
1339
+ properties: {
1340
+ centerPoint: entity.option.position,
1341
+ radius: entity.option.radius
1342
+ },
1343
+ geometry: {
1344
+ type: "Polygon",
1345
+ coordinates: []
1346
+ }
1347
+ };
1348
+ entity.graphic.addFeature(featureArr);
1349
+ // entity.graphic = new SGMap.DrawCircleHandler(entity.config);
1350
+ } else if (entity.type == "route") {
1351
+ hnMap.map.map.addLayer(entity.config_routeline);
1352
+ hnMap.map.map.addLayer(entity.config_routeplay);
1353
+ entity.createCar();
1354
+ entity.chunkData = entity.joinLinePoint();
1355
+ entity.start();
1356
+ } else {
1357
+ hnMap.map.map.addLayer(entity.config);
1358
+ }
1359
+ entity.show = true;
1360
+ }
1361
+ }, {
1362
+ key: "removeLevelEntity",
1363
+ value: function removeLevelEntity(entity) {
1364
+ if (entity) {
1365
+ if (entity.type == "circle") {
1366
+ entity.graphic.remove();
1367
+ entity.graphic.clearData();
1368
+ } else if (entity.type == "numPoint") {
1369
+ hnMap.map.map.removeLayer(entity.config.id);
1370
+ hnMap.map.map.removeSource(entity.config.id);
1371
+ hnMap.map.map.removeLayer(entity.configLabel.id);
1372
+ hnMap.map.map.removeSource(entity.configLabel.id);
1373
+ } else if (entity.type == "divPoint") {
1374
+ entity.graphic.remove();
1375
+ } else if (entity.type == "route") {
1376
+ hnMap.map.map.removeLayer(entity.config_routeline.id);
1377
+ hnMap.map.map.removeSource(entity.config_routeline.id);
1378
+ hnMap.map.map.removeLayer(entity.config_routeplay.id);
1379
+ hnMap.map.map.removeSource(entity.config_routeplay.id);
1380
+ entity.imgMarker.remove();
1381
+ } else {
1382
+ hnMap.map.map.removeLayer(entity.id);
1383
+ hnMap.map.map.removeSource(entity.id);
1384
+ }
1385
+ entity.show = false;
1040
1386
  }
1041
1387
  }
1042
1388
  }, {
1043
1389
  key: "clearEntity",
1044
1390
  value: function clearEntity() {
1391
+ var _this6 = this;
1392
+ this.children.forEach(function (v) {
1393
+ _this6.removeEntity(v.id);
1394
+ });
1045
1395
  this.children = [];
1046
- this.layerEntity.clearOverlays();
1047
1396
  }
1048
1397
  }, {
1049
1398
  key: "destroy",
1050
1399
  value: function destroy() {
1051
- var _this5 = this;
1400
+ var _this7 = this;
1052
1401
  this.clearEntity();
1053
1402
  hnMap.map.layerList = hnMap.map.layerList.filter(function (v) {
1054
- return v.id !== _this5.id;
1403
+ return v.id !== _this7.id;
1055
1404
  });
1056
1405
  }
1057
-
1058
1406
  // 添加属性弹窗
1059
1407
  }, {
1060
1408
  key: "addPopupByAttr",
1061
- value: function addPopupByAttr() {}
1062
-
1409
+ value: function addPopupByAttr() {
1410
+ var _this8 = this;
1411
+ // 如果已有弹窗,先关闭
1412
+ this.removePopup();
1413
+ this.infoWindow = new SGMap.Popup({
1414
+ offset: {
1415
+ bottom: [0, 0]
1416
+ },
1417
+ className: "my-attrPopup-class"
1418
+ });
1419
+ var handleClick = function handleClick(e) {
1420
+ var data = e.features[0].properties;
1421
+ // 创建弹窗内容
1422
+ var content = "";
1423
+ for (var key in data) {
1424
+ content += "<div>".concat(key, ": ").concat(data[key], "</div>");
1425
+ }
1426
+ _this8.infoWindow.setHTML(content);
1427
+ console.log("e.lngLat===", e.lngLat);
1428
+ _this8.infoWindow.setLngLat(e.lngLat).addTo(hnMap.map.map);
1429
+ };
1430
+ hnMap.map.map.on("click", this.config.id, handleClick);
1431
+ }
1063
1432
  // 添加自定义dom弹窗
1064
1433
  }, {
1065
1434
  key: "addCustomPopup",
1066
- value: function addCustomPopup(getCustomDom) {}
1435
+ value: function addCustomPopup(getCustomDom) {
1436
+ var _this9 = this;
1437
+ // 如果已有弹窗,先关闭
1438
+ this.removePopup();
1439
+ this.infoWindow = new SGMap.Popup({
1440
+ offset: {
1441
+ bottom: [0, 0]
1442
+ },
1443
+ className: "my-customPopup-class"
1444
+ });
1445
+ var handleClick = function handleClick(e) {
1446
+ var data = e.features[0].properties;
1447
+ var dom = getCustomDom(data);
1448
+ _this9.infoWindow.setHTML(dom);
1449
+ _this9.infoWindow.setLngLat(e.lngLat).addTo(hnMap.map.map);
1450
+ };
1451
+ hnMap.map.map.on("click", this.config.id, handleClick);
1452
+ }
1453
+ // 弹窗删除
1454
+ }, {
1455
+ key: "removePopup",
1456
+ value: function removePopup() {
1457
+ if (this.infoWindow) {
1458
+ this.infoWindow.remove();
1459
+ }
1460
+ }
1067
1461
  }]);
1068
1462
  }();
1069
1463
  var fn = {
@@ -1077,9 +1471,11 @@
1077
1471
  var mars3d_entity = /*#__PURE__*/function () {
1078
1472
  function mars3d_entity(hnMap) {
1079
1473
  _classCallCheck(this, mars3d_entity);
1474
+ this.option = null;
1475
+ this.event = {};
1476
+ this.graphic = null;
1080
1477
  this.event = {};
1081
1478
  }
1082
-
1083
1479
  // 添加属性弹窗
1084
1480
  return _createClass(mars3d_entity, [{
1085
1481
  key: "addPopupByAttr",
@@ -1093,13 +1489,13 @@
1093
1489
  });
1094
1490
  });
1095
1491
  }
1096
-
1097
1492
  // 添加自定义dom弹窗
1098
1493
  }, {
1099
1494
  key: "addCustomPopup",
1100
1495
  value: function addCustomPopup(getCustomDom) {
1101
- this.graphic.bindPopup(/*#__PURE__*/function () {
1102
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
1496
+ var _this = this;
1497
+ this.graphic.bindPopup(function (event) {
1498
+ return __awaiter(_this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
1103
1499
  var data;
1104
1500
  return _regenerator().w(function (_context) {
1105
1501
  while (1) switch (_context.n) {
@@ -1118,10 +1514,7 @@
1118
1514
  }
1119
1515
  }, _callee);
1120
1516
  }));
1121
- return function (_x) {
1122
- return _ref.apply(this, arguments);
1123
- };
1124
- }(), {
1517
+ }, {
1125
1518
  offsetY: -20
1126
1519
  });
1127
1520
  }
@@ -1134,21 +1527,23 @@
1134
1527
  }, {
1135
1528
  key: "destroy",
1136
1529
  value: function destroy() {
1530
+ console.log(this.graphic, "=====this.graphic===");
1137
1531
  this.graphic.destroy();
1138
1532
  }
1139
1533
  }, {
1140
1534
  key: "on",
1141
1535
  value: function on(eventType, callback) {
1536
+ var _this2 = this;
1142
1537
  this.off(eventType);
1143
1538
  switch (eventType) {
1144
- case 'click':
1539
+ case "click":
1145
1540
  this.event[eventType] = function () {
1146
- callback(event);
1541
+ callback(_this2.option.data);
1147
1542
  };
1148
1543
  break;
1149
1544
  }
1150
1545
  this.graphic.on(eventType, this.event[eventType]);
1151
- }
1546
+ } // 监听事件
1152
1547
  }, {
1153
1548
  key: "off",
1154
1549
  value: function off(eventType) {
@@ -1163,11 +1558,12 @@
1163
1558
  var gaode_entity = /*#__PURE__*/function () {
1164
1559
  function gaode_entity(hnMap) {
1165
1560
  _classCallCheck(this, gaode_entity);
1166
- _defineProperty(this, "infoWindow", null);
1167
- _defineProperty(this, "hnMap", null);
1561
+ this.infoWindow = null;
1562
+ this.hnMap = null;
1563
+ this.config = null;
1564
+ this.graphic = null;
1168
1565
  this.hnMap = hnMap;
1169
1566
  }
1170
-
1171
1567
  // 添加属性弹窗
1172
1568
  return _createClass(gaode_entity, [{
1173
1569
  key: "addPopupByAttr",
@@ -1187,7 +1583,6 @@
1187
1583
  };
1188
1584
  this.graphic.on('click', handleClick);
1189
1585
  }
1190
-
1191
1586
  // 添加自定义dom弹窗
1192
1587
  }, {
1193
1588
  key: "addCustomPopup",
@@ -1226,47 +1621,163 @@
1226
1621
  }]);
1227
1622
  }();
1228
1623
 
1229
- var point = (function (hnMap) {
1230
- var defaultOption = {
1231
- id: "",
1232
- position: [],
1233
- color: "#ffffff",
1234
- opacity: 1,
1235
- size: 6,
1236
- text: "",
1237
- fontSize: 12,
1238
- fontColor: "#ffffff",
1239
- fontOpacity: 1,
1240
- fontOffset: [0, 0],
1241
- outline: false,
1242
- outlineColor: "#ffffff",
1243
- outlineWidth: 20,
1244
- outlineOpacity: 0.5,
1245
- textOutline: false,
1246
- textOutlineColor: "#000000",
1247
- textOutlineOpacity: 0.6,
1248
- textOutlineWidth: 2,
1249
- textBackgroundColor: "",
1250
- textBackgroundOpacity: 0.5,
1251
- scaleByDistance: true,
1252
- distanceDisplayCondition: false,
1253
- distanceDisplayCondition_far: Number.MAX_VALUE,
1254
- distanceDisplayCondition_near: 0,
1255
- data: null
1256
- };
1257
- var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
1258
- function mars3d_class(option) {
1259
- var _this;
1260
- _classCallCheck(this, mars3d_class);
1261
- _this = _callSuper(this, mars3d_class);
1262
- _defineProperty(_this, "type", 'point');
1263
- _defineProperty(_this, "id", null);
1264
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
1265
- _defineProperty(_this, "config", null);
1266
- _defineProperty(_this, "graphic", null);
1267
- _this.id = option.id;
1268
- deepMerge(_this.option, option);
1269
- _this.config = _this.formatConfig(_this.option);
1624
+ var siji_entity = /*#__PURE__*/function () {
1625
+ function siji_entity(hnMap) {
1626
+ _classCallCheck(this, siji_entity);
1627
+ this.event = {};
1628
+ this.infoWindow = null;
1629
+ this.hnMap = null;
1630
+ this.config = null;
1631
+ this.graphic = null;
1632
+ this.option = null;
1633
+ this.type = null;
1634
+ this.show = false;
1635
+ this.hnMap = hnMap;
1636
+ this.event = {};
1637
+ this.show = false;
1638
+ }
1639
+ // 添加属性弹窗
1640
+ return _createClass(siji_entity, [{
1641
+ key: "addPopupByAttr",
1642
+ value: function addPopupByAttr() {
1643
+ var _this = this;
1644
+ alert("添加属性弹窗");
1645
+ console.log(this.config);
1646
+ console.log(this.graphic);
1647
+ // 如果已有弹窗,先关闭
1648
+ this.removePopup();
1649
+ this.infoWindow = new SGMap.Popup({
1650
+ offset: {
1651
+ bottom: [0, 0]
1652
+ },
1653
+ className: "my-popupAttr-class"
1654
+ });
1655
+ var handleClick = function handleClick(e) {
1656
+ alert("添加属性弹窗111");
1657
+ // const data = e.features[0].properties;
1658
+ var data = _this.option.data;
1659
+ // 创建弹窗内容
1660
+ var content = "";
1661
+ for (var key in data) {
1662
+ content += "<div>".concat(key, ": ").concat(data[key], "</div>");
1663
+ }
1664
+ _this.infoWindow.setHTML(content);
1665
+ _this.infoWindow.setLngLat(e.lngLat).addTo(_this.hnMap.map.map);
1666
+ };
1667
+ this.hnMap.map.map.on("click", this.config.id, handleClick);
1668
+ }
1669
+ // 添加自定义dom弹窗
1670
+ }, {
1671
+ key: "addCustomPopup",
1672
+ value: function addCustomPopup(getCustomDom) {
1673
+ var _this2 = this;
1674
+ this.removePopup();
1675
+ this.infoWindow = new SGMap.Popup({
1676
+ offset: {
1677
+ bottom: [0, 0]
1678
+ },
1679
+ className: "my-customPopup-class"
1680
+ });
1681
+ var handleClick = function handleClick(e) {
1682
+ var data = _this2.option.data;
1683
+ // const data = e.features[0].properties;
1684
+ var dom = getCustomDom(data);
1685
+ _this2.infoWindow.setHTML(dom);
1686
+ _this2.infoWindow.setLngLat(e.lngLat).addTo(_this2.hnMap.map.map);
1687
+ };
1688
+ this.hnMap.map.map.on("click", this.config.id, handleClick);
1689
+ }
1690
+ // 弹窗删除
1691
+ }, {
1692
+ key: "removePopup",
1693
+ value: function removePopup() {
1694
+ if (this.infoWindow) {
1695
+ this.infoWindow.remove();
1696
+ }
1697
+ }
1698
+ }, {
1699
+ key: "flyTo",
1700
+ value: function flyTo() {
1701
+ var zoom = this.hnMap.map.map.getZoom();
1702
+ this.hnMap.map.map.flyTo({
1703
+ duration: 1000,
1704
+ // 持续时间
1705
+ zoom: zoom,
1706
+ center: this.type == "line" || this.type == "dash" || this.type == "flicker" || this.type == "flow" || this.type == "arrow" || this.type == "mapLabel" || this.type == "polygon" || this.type == "rectangle" ? this.option.position[0] : this.type == "route" ? [this.option.position[0][0], this.option.position[0][1]] : this.option.position
1707
+ });
1708
+ }
1709
+ }, {
1710
+ key: "destroy",
1711
+ value: function destroy() {
1712
+ this.hnMap.map.map.removeLayer(this.config.id);
1713
+ this.hnMap.map.map.removeSource(this.config.id);
1714
+ }
1715
+ }, {
1716
+ key: "on",
1717
+ value: function on(eventType, eventId, callback) {
1718
+ var _this3 = this;
1719
+ this.off(eventType, eventId);
1720
+ switch (eventType) {
1721
+ case "click":
1722
+ this.event[eventType] = function () {
1723
+ callback(_this3.option.data);
1724
+ };
1725
+ break;
1726
+ }
1727
+ this.hnMap.map.map.on(eventType, eventId, this.event[eventType]);
1728
+ } // 监听事件
1729
+ }, {
1730
+ key: "off",
1731
+ value: function off(eventType, eventId) {
1732
+ if (this.event[eventType]) {
1733
+ this.hnMap.map.map.off(eventType, eventId, this.event[eventType]);
1734
+ delete this.event[eventType];
1735
+ }
1736
+ }
1737
+ }]);
1738
+ }();
1739
+
1740
+ var point = (function (hnMap) {
1741
+ var defaultOption = {
1742
+ id: "",
1743
+ position: [],
1744
+ color: "#ffffff",
1745
+ opacity: 1,
1746
+ size: 6,
1747
+ text: "",
1748
+ fontSize: 12,
1749
+ fontColor: "#ffffff",
1750
+ fontOpacity: 1,
1751
+ fontOffset: [0, 0],
1752
+ outline: false,
1753
+ outlineColor: "#ffffff",
1754
+ outlineWidth: 20,
1755
+ outlineOpacity: 0.5,
1756
+ textOutline: false,
1757
+ textOutlineColor: "#000000",
1758
+ textOutlineOpacity: 0.6,
1759
+ textOutlineWidth: 2,
1760
+ textBackgroundColor: "",
1761
+ textBackgroundOpacity: 0.5,
1762
+ scaleByDistance: true,
1763
+ distanceDisplayCondition: false,
1764
+ distanceDisplayCondition_far: 1,
1765
+ distanceDisplayCondition_near: 18,
1766
+ data: null
1767
+ };
1768
+ var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
1769
+ function mars3d_class(option) {
1770
+ var _this;
1771
+ _classCallCheck(this, mars3d_class);
1772
+ _this = _callSuper(this, mars3d_class, [hnMap]);
1773
+ _this.type = "point";
1774
+ _this.id = null;
1775
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
1776
+ _this.config = null;
1777
+ _this.graphic = null;
1778
+ _this.id = option.id;
1779
+ deepMerge(_this.option, option);
1780
+ _this.config = _this.formatConfig(_this.option);
1270
1781
  _this.graphic = new mars3d.graphic.PointEntity(_this.config);
1271
1782
  return _this;
1272
1783
  }
@@ -1274,6 +1785,8 @@
1274
1785
  return _createClass(mars3d_class, [{
1275
1786
  key: "formatConfig",
1276
1787
  value: function formatConfig(option) {
1788
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
1789
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
1277
1790
  return {
1278
1791
  id: option.id,
1279
1792
  position: option.position,
@@ -1288,8 +1801,8 @@
1288
1801
  clampToGround: !option.position[2],
1289
1802
  scaleByDistance: option.scaleByDistance,
1290
1803
  distanceDisplayCondition: option.distanceDisplayCondition,
1291
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
1292
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
1804
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
1805
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
1293
1806
  label: {
1294
1807
  text: option.text,
1295
1808
  font_size: option.fontSize,
@@ -1305,8 +1818,8 @@
1305
1818
  pixelOffset: option.fontOffset,
1306
1819
  scaleByDistance: option.fontScaleByDistance,
1307
1820
  distanceDisplayCondition: option.fontDistanceDisplayCondition,
1308
- distanceDisplayCondition_far: option.fontDistanceDisplayCondition_far,
1309
- distanceDisplayCondition_near: option.fontDistanceDisplayCondition_near
1821
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
1822
+ distanceDisplayCondition_near: distanceDisplayCondition_near
1310
1823
  }
1311
1824
  },
1312
1825
  attr: option.data
@@ -1325,11 +1838,11 @@
1325
1838
  function gaode_class(option) {
1326
1839
  var _this2;
1327
1840
  _classCallCheck(this, gaode_class);
1328
- _this2 = _callSuper(this, gaode_class);
1329
- _defineProperty(_this2, "id", null);
1330
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
1331
- _defineProperty(_this2, "config", null);
1332
- _defineProperty(_this2, "graphic", null);
1841
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
1842
+ _this2.id = null;
1843
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
1844
+ _this2.config = null;
1845
+ _this2.graphic = null;
1333
1846
  _this2.id = option.id;
1334
1847
  deepMerge(_this2.option, option);
1335
1848
  _this2.config = _this2.formatConfig(_this2.option);
@@ -1365,9 +1878,94 @@
1365
1878
  }
1366
1879
  }]);
1367
1880
  }(gaode_entity);
1881
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
1882
+ function siji_class(option) {
1883
+ var _this3;
1884
+ _classCallCheck(this, siji_class);
1885
+ _this3 = _callSuper(this, siji_class, [hnMap]);
1886
+ _this3.type = "point";
1887
+ _this3.id = null;
1888
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
1889
+ _this3.config = null;
1890
+ _this3.id = option.id;
1891
+ deepMerge(_this3.option, option);
1892
+ _this3.config = _this3.formatConfig(_this3.option);
1893
+ return _this3;
1894
+ }
1895
+ _inherits(siji_class, _siji_entity);
1896
+ return _createClass(siji_class, [{
1897
+ key: "formatConfig",
1898
+ value: function formatConfig(option) {
1899
+ var config = {};
1900
+ config = {
1901
+ id: option.id,
1902
+ type: "circle",
1903
+ source: {
1904
+ type: "geojson",
1905
+ data: {
1906
+ type: "FeatureCollection",
1907
+ features: [{
1908
+ type: "Feature",
1909
+ geometry: {
1910
+ type: "Point",
1911
+ coordinates: option.position
1912
+ },
1913
+ properties: Object.assign({
1914
+ id: option.id
1915
+ }, option.data)
1916
+ }]
1917
+ }
1918
+ },
1919
+ paint: {
1920
+ "circle-opacity": Number(option.opacity),
1921
+ "circle-radius": Number(option.size),
1922
+ "circle-color": option.color,
1923
+ "circle-stroke-color": option.outlineColor,
1924
+ "circle-stroke-width": option.outlineWidth,
1925
+ "circle-stroke-opacity": Number(option.outlineOpacity) // 边框样式
1926
+ } // 填充样式
1927
+ };
1928
+ return config;
1929
+ }
1930
+ }, {
1931
+ key: "set",
1932
+ value: function set(option) {
1933
+ console.log("=====set point====", option);
1934
+ deepMerge(this.option, option);
1935
+ this.config = this.formatConfig(this.option);
1936
+ var mySource = hnMap.map.map.getSource(this.config.id);
1937
+ mySource.setData({
1938
+ type: "FeatureCollection",
1939
+ features: [{
1940
+ type: "Feature",
1941
+ properties: {
1942
+ name: this.option.text
1943
+ },
1944
+ geometry: {
1945
+ type: "Point",
1946
+ coordinates: this.option.position
1947
+ }
1948
+ }]
1949
+ });
1950
+ for (var key in this.config) {
1951
+ if (this.config.hasOwnProperty(key)) {
1952
+ if (key == "paint") {
1953
+ for (var key2 in this.config[key]) {
1954
+ if (this.config[key].hasOwnProperty(key2)) {
1955
+ // 遍历 paint 属性
1956
+ hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "circle-opacity" || key2 == "circle-stroke-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
1957
+ }
1958
+ }
1959
+ }
1960
+ }
1961
+ }
1962
+ }
1963
+ }]);
1964
+ }(siji_entity);
1368
1965
  var fn = {
1369
1966
  mars3d: mars3d_class,
1370
- gaode: gaode_class
1967
+ gaode: gaode_class,
1968
+ siji: siji_class
1371
1969
  };
1372
1970
  return fn[hnMap.mapType];
1373
1971
  });
@@ -1384,20 +1982,20 @@
1384
1982
  scale: 1,
1385
1983
  scaleByDistance: true,
1386
1984
  distanceDisplayCondition: false,
1387
- distanceDisplayCondition_far: Number.MAX_VALUE,
1388
- distanceDisplayCondition_near: 0,
1985
+ distanceDisplayCondition_far: 1,
1986
+ distanceDisplayCondition_near: 18,
1389
1987
  data: null
1390
1988
  };
1391
1989
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
1392
1990
  function mars3d_class(option) {
1393
1991
  var _this;
1394
1992
  _classCallCheck(this, mars3d_class);
1395
- _this = _callSuper(this, mars3d_class);
1396
- _defineProperty(_this, "type", 'numPoint');
1397
- _defineProperty(_this, "id", null);
1398
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
1399
- _defineProperty(_this, "config", null);
1400
- _defineProperty(_this, "graphic", null);
1993
+ _this = _callSuper(this, mars3d_class, [hnMap]);
1994
+ _this.type = "numPoint";
1995
+ _this.id = null;
1996
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
1997
+ _this.config = null;
1998
+ _this.graphic = null;
1401
1999
  _this.id = option.id;
1402
2000
  deepMerge(_this.option, option);
1403
2001
  _this.config = _this.formatConfig(_this.option);
@@ -1408,6 +2006,8 @@
1408
2006
  return _createClass(mars3d_class, [{
1409
2007
  key: "formatConfig",
1410
2008
  value: function formatConfig(option) {
2009
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
2010
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
1411
2011
  return {
1412
2012
  id: option.id,
1413
2013
  position: option.position,
@@ -1422,8 +2022,8 @@
1422
2022
  clampToGround: !option.position[2],
1423
2023
  scaleByDistance: option.scaleByDistance,
1424
2024
  distanceDisplayCondition: option.distanceDisplayCondition,
1425
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
1426
- distanceDisplayCondition_near: option.distanceDisplayCondition_near
2025
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
2026
+ distanceDisplayCondition_near: distanceDisplayCondition_near
1427
2027
  },
1428
2028
  attr: option.data
1429
2029
  };
@@ -1441,11 +2041,11 @@
1441
2041
  function gaode_class(option) {
1442
2042
  var _this2;
1443
2043
  _classCallCheck(this, gaode_class);
1444
- _this2 = _callSuper(this, gaode_class);
1445
- _defineProperty(_this2, "id", null);
1446
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
1447
- _defineProperty(_this2, "config", null);
1448
- _defineProperty(_this2, "graphic", null);
2044
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
2045
+ _this2.id = null;
2046
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
2047
+ _this2.config = null;
2048
+ _this2.graphic = null;
1449
2049
  _this2.id = option.id;
1450
2050
  deepMerge(_this2.option, option);
1451
2051
  _this2.config = _this2.formatConfig(_this2.option);
@@ -1462,7 +2062,7 @@
1462
2062
  id: option.id,
1463
2063
  position: new AMap.LngLat(amapPosition[0], amapPosition[1]),
1464
2064
  content: markerContent,
1465
- anchor: 'top-center',
2065
+ anchor: "top-center",
1466
2066
  offset: [0, -20],
1467
2067
  extData: {
1468
2068
  id: option.id,
@@ -1479,9 +2079,164 @@
1479
2079
  }
1480
2080
  }]);
1481
2081
  }(gaode_entity);
2082
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
2083
+ function siji_class(option) {
2084
+ var _this3;
2085
+ _classCallCheck(this, siji_class);
2086
+ _this3 = _callSuper(this, siji_class, [hnMap]);
2087
+ _this3.type = "numPoint";
2088
+ _this3.id = null;
2089
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
2090
+ _this3.config = null;
2091
+ _this3.configLabel = null;
2092
+ _this3.id = option.id;
2093
+ deepMerge(_this3.option, option);
2094
+ _this3.config = _this3.formatConfig(_this3.option);
2095
+ _this3.configLabel = _this3.formatConfigNum(_this3.option);
2096
+ return _this3;
2097
+ }
2098
+ _inherits(siji_class, _siji_entity);
2099
+ return _createClass(siji_class, [{
2100
+ key: "formatConfig",
2101
+ value: function formatConfig(option) {
2102
+ var config = {};
2103
+ config = {
2104
+ id: option.id,
2105
+ type: "circle",
2106
+ source: {
2107
+ type: "geojson",
2108
+ data: {
2109
+ type: "FeatureCollection",
2110
+ features: [{
2111
+ type: "Feature",
2112
+ geometry: {
2113
+ type: "Point",
2114
+ coordinates: option.position
2115
+ },
2116
+ properties: {
2117
+ name: option.text
2118
+ }
2119
+ }]
2120
+ }
2121
+ },
2122
+ paint: {
2123
+ "circle-opacity": Number(option.opacity),
2124
+ "circle-radius": Number(option.size),
2125
+ "circle-color": option.color
2126
+ } // 填充样式
2127
+ };
2128
+ return config;
2129
+ }
2130
+ }, {
2131
+ key: "formatConfigNum",
2132
+ value: function formatConfigNum(option) {
2133
+ var configLabel = {};
2134
+ configLabel = {
2135
+ id: "num_" + option.id,
2136
+ type: "symbol",
2137
+ source: {
2138
+ type: "geojson",
2139
+ data: {
2140
+ type: "FeatureCollection",
2141
+ features: [{
2142
+ type: "Feature",
2143
+ geometry: {
2144
+ type: "Point",
2145
+ coordinates: option.position
2146
+ },
2147
+ properties: {
2148
+ name: option.num
2149
+ }
2150
+ }]
2151
+ }
2152
+ },
2153
+ layout: {
2154
+ "icon-anchor": "center",
2155
+ "text-field": "{name}",
2156
+ "text-size": Number(option.size),
2157
+ "text-anchor": "center" // 顶部对齐
2158
+ },
2159
+ // 文本样式
2160
+ paint: {
2161
+ "text-color": option.fontColor
2162
+ } // 填充样式
2163
+ };
2164
+ return configLabel;
2165
+ }
2166
+ }, {
2167
+ key: "set",
2168
+ value: function set(option) {
2169
+ deepMerge(this.option, option);
2170
+ this.config = this.formatConfig(this.option);
2171
+ this.configLabel = this.formatConfigNum(this.option);
2172
+ var mySource = hnMap.map.map.getSource(this.config.id);
2173
+ mySource.setData({
2174
+ type: "FeatureCollection",
2175
+ features: [{
2176
+ type: "Feature",
2177
+ properties: {
2178
+ name: this.option.text
2179
+ },
2180
+ geometry: {
2181
+ type: "Point",
2182
+ coordinates: this.option.position
2183
+ }
2184
+ }]
2185
+ });
2186
+ for (var key in this.config) {
2187
+ if (this.config.hasOwnProperty(key)) {
2188
+ if (key == "paint") {
2189
+ for (var key2 in this.config[key]) {
2190
+ if (this.config[key].hasOwnProperty(key2)) {
2191
+ // 遍历 paint 属性
2192
+ hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "circle-opacity" ? Number(this.config[key][key2]) : this.config[key][key2]);
2193
+ }
2194
+ }
2195
+ }
2196
+ }
2197
+ }
2198
+ // 数字更改
2199
+ var mySource_num = hnMap.map.map.getSource(this.configLabel.id);
2200
+ mySource_num.setData({
2201
+ type: "FeatureCollection",
2202
+ features: [{
2203
+ type: "Feature",
2204
+ properties: {
2205
+ name: this.option.num
2206
+ },
2207
+ geometry: {
2208
+ type: "Point",
2209
+ coordinates: this.option.position
2210
+ }
2211
+ }]
2212
+ });
2213
+ for (var _key in this.configLabel) {
2214
+ if (this.configLabel.hasOwnProperty(_key)) {
2215
+ if (_key == "paint") {
2216
+ for (var _key2 in this.configLabel[_key]) {
2217
+ if (this.configLabel[_key].hasOwnProperty(_key2)) {
2218
+ // 遍历 paint 属性
2219
+ hnMap.map.map.setPaintProperty(this.configLabel.id, _key2, this.configLabel[_key][_key2]);
2220
+ }
2221
+ }
2222
+ }
2223
+ if (_key == "layout") {
2224
+ for (var _key3 in this.configLabel[_key]) {
2225
+ if (this.configLabel[_key].hasOwnProperty(_key3)) {
2226
+ // 遍历 layout 属性
2227
+ hnMap.map.map.setLayoutProperty(this.configLabel.id, _key3, _key3 == "text-size" ? Number(this.configLabel[_key][_key3]) : this.configLabel[_key][_key3]);
2228
+ }
2229
+ }
2230
+ }
2231
+ }
2232
+ }
2233
+ }
2234
+ }]);
2235
+ }(siji_entity);
1482
2236
  var fn = {
1483
2237
  mars3d: mars3d_class,
1484
- gaode: gaode_class
2238
+ gaode: gaode_class,
2239
+ siji: siji_class
1485
2240
  };
1486
2241
  return fn[hnMap.mapType];
1487
2242
  });
@@ -1512,19 +2267,19 @@
1512
2267
  offset: [0, 0],
1513
2268
  scaleByDistance: true,
1514
2269
  distanceDisplayCondition: false,
1515
- distanceDisplayCondition_far: Number.MAX_VALUE,
1516
- distanceDisplayCondition_near: 0,
2270
+ distanceDisplayCondition_far: 1,
2271
+ distanceDisplayCondition_near: 18,
1517
2272
  data: null
1518
2273
  };
1519
2274
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
1520
2275
  function mars3d_class(option) {
1521
2276
  var _this;
1522
2277
  _classCallCheck(this, mars3d_class);
1523
- _this = _callSuper(this, mars3d_class);
1524
- _defineProperty(_this, "id", null);
1525
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
1526
- _defineProperty(_this, "config", null);
1527
- _defineProperty(_this, "graphic", null);
2278
+ _this = _callSuper(this, mars3d_class, [hnMap]);
2279
+ _this.id = null;
2280
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
2281
+ _this.config = null;
2282
+ _this.graphic = null;
1528
2283
  _this.id = option.id;
1529
2284
  deepMerge(_this.option, option);
1530
2285
  _this.config = _this.formatConfig(_this.option);
@@ -1535,6 +2290,8 @@
1535
2290
  return _createClass(mars3d_class, [{
1536
2291
  key: "formatConfig",
1537
2292
  value: function formatConfig(option) {
2293
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
2294
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
1538
2295
  return {
1539
2296
  id: option.id,
1540
2297
  position: option.position,
@@ -1549,8 +2306,8 @@
1549
2306
  pixelOffset: option.offset,
1550
2307
  scaleByDistance: option.scaleByDistance,
1551
2308
  distanceDisplayCondition: option.distanceDisplayCondition,
1552
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
1553
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
2309
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
2310
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
1554
2311
  visibleDepth: false
1555
2312
  },
1556
2313
  scaleByDistance: option.scaleByDistance,
@@ -1573,7 +2330,6 @@
1573
2330
  this.config = this.formatConfig(this.option);
1574
2331
  this.graphic.setOptions(this.config);
1575
2332
  }
1576
-
1577
2333
  // flyTo(option = {}) {
1578
2334
  // let config = {}
1579
2335
  // if(option.height){
@@ -1593,12 +2349,12 @@
1593
2349
  function gaode_class(option) {
1594
2350
  var _this2;
1595
2351
  _classCallCheck(this, gaode_class);
1596
- _this2 = _callSuper(this, gaode_class);
1597
- _defineProperty(_this2, "type", 'imagePoint');
1598
- _defineProperty(_this2, "id", null);
1599
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
1600
- _defineProperty(_this2, "config", null);
1601
- _defineProperty(_this2, "graphic", null);
2352
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
2353
+ _this2.type = "imagePoint";
2354
+ _this2.id = null;
2355
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
2356
+ _this2.config = null;
2357
+ _this2.graphic = null;
1602
2358
  _this2.id = option.id;
1603
2359
  deepMerge(_this2.option, option);
1604
2360
  _this2.config = _this2.formatConfig(_this2.option);
@@ -1623,28 +2379,102 @@
1623
2379
  size: new AMap.Size(option.height, option.width)
1624
2380
  }),
1625
2381
  angle: 360 - option.rotation,
1626
- anchor: 'center',
2382
+ anchor: "center",
1627
2383
  label: {
1628
- direction: 'center',
2384
+ direction: "center",
1629
2385
  offset: new AMap.Pixel(option.offset[0], option.offset[1]),
1630
2386
  //设置文本标注偏移量
1631
2387
  content: content
1632
2388
  }
1633
2389
  };
1634
2390
  }
2391
+ }]);
2392
+ }(gaode_entity);
2393
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
2394
+ function siji_class(option) {
2395
+ var _this3;
2396
+ _classCallCheck(this, siji_class);
2397
+ _this3 = _callSuper(this, siji_class, [hnMap]);
2398
+ _this3.type = "imagePoint";
2399
+ _this3.id = null;
2400
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
2401
+ _this3.config = null;
2402
+ _this3.graphic = null;
2403
+ _this3.id = option.id;
2404
+ deepMerge(_this3.option, option);
2405
+ _this3.config = _this3.formatConfig(_this3.option);
2406
+ return _this3;
2407
+ }
2408
+ _inherits(siji_class, _siji_entity);
2409
+ return _createClass(siji_class, [{
2410
+ key: "formatConfig",
2411
+ value: function formatConfig(option) {
2412
+ var config = {};
2413
+ config = {
2414
+ id: option.id,
2415
+ type: "symbol",
2416
+ source: {
2417
+ type: "geojson",
2418
+ data: {
2419
+ type: "FeatureCollection",
2420
+ features: [{
2421
+ type: "Feature",
2422
+ geometry: {
2423
+ type: "Point",
2424
+ coordinates: option.position.map(function (num) {
2425
+ return Number(num);
2426
+ })
2427
+ },
2428
+ properties: {
2429
+ name: ""
2430
+ }
2431
+ }]
2432
+ }
2433
+ },
2434
+ layout: {
2435
+ "icon-image": option.id + "_image",
2436
+ "icon-size": Number(option.width) / Number(option.height)
2437
+ }
2438
+ };
2439
+ return config;
2440
+ }
1635
2441
  }, {
1636
2442
  key: "set",
1637
2443
  value: function set(option) {
1638
2444
  deepMerge(this.option, option);
1639
2445
  this.config = this.formatConfig(this.option);
1640
- this.graphic.setOptions(this.config);
1641
- this.graphic.setAngle(this.config.angle);
2446
+ var mySource = hnMap.map.map.getSource(this.config.id);
2447
+ mySource.setData({
2448
+ type: "FeatureCollection",
2449
+ features: [{
2450
+ type: "Feature",
2451
+ geometry: {
2452
+ type: "Point",
2453
+ coordinates: this.option.position.map(function (num) {
2454
+ return Number(num);
2455
+ })
2456
+ }
2457
+ }]
2458
+ });
2459
+ for (var key in this.config) {
2460
+ if (this.config.hasOwnProperty(key)) {
2461
+ if (key == "layout") {
2462
+ for (var key2 in this.config[key]) {
2463
+ if (this.config[key].hasOwnProperty(key2)) {
2464
+ // 遍历 layout 属性
2465
+ hnMap.map.map.setLayoutProperty(this.config.id, key2, this.config[key][key2]);
2466
+ }
2467
+ }
2468
+ }
2469
+ }
2470
+ }
1642
2471
  }
1643
2472
  }]);
1644
- }(gaode_entity);
2473
+ }(siji_entity);
1645
2474
  var fn = {
1646
2475
  mars3d: mars3d_class,
1647
- gaode: gaode_class
2476
+ gaode: gaode_class,
2477
+ siji: siji_class
1648
2478
  };
1649
2479
  return fn[hnMap.mapType];
1650
2480
  });
@@ -1669,20 +2499,20 @@
1669
2499
  offset: [0, 0],
1670
2500
  scaleByDistance: true,
1671
2501
  distanceDisplayCondition: false,
1672
- distanceDisplayCondition_far: Number.MAX_VALUE,
1673
- distanceDisplayCondition_near: 0,
2502
+ distanceDisplayCondition_far: 1,
2503
+ distanceDisplayCondition_near: 18,
1674
2504
  data: null
1675
2505
  };
1676
2506
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
1677
2507
  function mars3d_class(option) {
1678
2508
  var _this;
1679
2509
  _classCallCheck(this, mars3d_class);
1680
- _this = _callSuper(this, mars3d_class);
1681
- _defineProperty(_this, "type", 'divPoint');
1682
- _defineProperty(_this, "id", null);
1683
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
1684
- _defineProperty(_this, "config", null);
1685
- _defineProperty(_this, "graphic", null);
2510
+ _this = _callSuper(this, mars3d_class, [hnMap]);
2511
+ _this.type = "divPoint";
2512
+ _this.id = null;
2513
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
2514
+ _this.config = null;
2515
+ _this.graphic = null;
1686
2516
  _this.id = option.id;
1687
2517
  deepMerge(_this.option, option);
1688
2518
  _this.config = _this.formatConfig(_this.option);
@@ -1693,6 +2523,8 @@
1693
2523
  return _createClass(mars3d_class, [{
1694
2524
  key: "formatConfig",
1695
2525
  value: function formatConfig(option) {
2526
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
2527
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
1696
2528
  return {
1697
2529
  id: option.id,
1698
2530
  position: option.position,
@@ -1702,8 +2534,8 @@
1702
2534
  offsetY: option.offset[1],
1703
2535
  scaleByDistance: option.scaleByDistance,
1704
2536
  distanceDisplayCondition: option.distanceDisplayCondition,
1705
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
1706
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
2537
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
2538
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
1707
2539
  clampToGround: !option.position[2],
1708
2540
  horizontalOrigin: HorizontalOrigin[option.horizontalOrigin],
1709
2541
  verticalOrigin: VerticalOrigin[option.verticalOrigin]
@@ -1725,9 +2557,63 @@
1725
2557
  }
1726
2558
  }]);
1727
2559
  }(mars3d_entity);
2560
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
2561
+ function siji_class(option) {
2562
+ var _this2;
2563
+ _classCallCheck(this, siji_class);
2564
+ _this2 = _callSuper(this, siji_class, [hnMap]);
2565
+ _this2.type = "divPoint";
2566
+ _this2.id = null;
2567
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
2568
+ _this2.config = null;
2569
+ _this2.graphic = null;
2570
+ _this2.id = option.id;
2571
+ deepMerge(_this2.option, option);
2572
+ _this2.config = _this2.formatConfig(_this2.option);
2573
+ _this2.graphic = new SGMap.Marker(_this2.config);
2574
+ return _this2;
2575
+ }
2576
+ _inherits(siji_class, _siji_entity);
2577
+ return _createClass(siji_class, [{
2578
+ key: "formatConfig",
2579
+ value: function formatConfig(option) {
2580
+ var el = document.createElement("div");
2581
+ el.className = "marker";
2582
+ el.id = option.id;
2583
+ el.innerHTML = option.html;
2584
+ // el.style.backgroundImage =
2585
+ // 'url("https://map.sgcc.com.cn/products/js-sdk/v3/assets/images/markers_new2_4ab0bc5_78.png")';
2586
+ el.style.width = "0";
2587
+ el.style.height = "0";
2588
+ return {
2589
+ id: option.id,
2590
+ element: el,
2591
+ anchor: "center",
2592
+ offset: option.offset
2593
+ };
2594
+ }
2595
+ }, {
2596
+ key: "set",
2597
+ value: function set(option) {
2598
+ deepMerge(this.option, option);
2599
+ this.config = this.formatConfig(this.option);
2600
+ if (this.graphic) {
2601
+ this.graphic.remove();
2602
+ }
2603
+ this.graphic = new SGMap.Marker(this.config);
2604
+ this.graphic.setLngLat(option.position).addTo(hnMap.map.map);
2605
+ }
2606
+ }, {
2607
+ key: "openPopup",
2608
+ value: function openPopup() {
2609
+ this.graphic.openPopup();
2610
+ }
2611
+ }]);
2612
+ }(siji_entity);
1728
2613
  var fn = {
1729
2614
  mars3d: mars3d_class,
1730
- gaode: mars3d_class
2615
+ gaode: mars3d_class,
2616
+ siji: siji_class
1731
2617
  };
1732
2618
  return fn[hnMap.mapType];
1733
2619
  });
@@ -1735,14 +2621,14 @@
1735
2621
  var label = (function (hnMap) {
1736
2622
  var defaultOption = {
1737
2623
  id: "",
1738
- type: 'label',
2624
+ type: "label",
1739
2625
  position: [],
1740
2626
  text: "",
1741
2627
  fontSize: 16,
1742
- fontWeight: 'normal',
2628
+ fontWeight: "normal",
1743
2629
  fontFamily: "楷体",
1744
2630
  color: "#000000",
1745
- background: '',
2631
+ background: "",
1746
2632
  opacity: 1,
1747
2633
  outline: false,
1748
2634
  outlineColor: "#ffffff",
@@ -1752,26 +2638,26 @@
1752
2638
  angle: 0,
1753
2639
  scaleByDistance: true,
1754
2640
  distanceDisplayCondition: false,
1755
- distanceDisplayCondition_far: Number.MAX_VALUE,
1756
- distanceDisplayCondition_near: 0,
2641
+ distanceDisplayCondition_far: 1,
2642
+ distanceDisplayCondition_near: 18,
1757
2643
  data: null
1758
2644
  };
1759
2645
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
1760
2646
  function mars3d_class(option) {
1761
2647
  var _this;
1762
2648
  _classCallCheck(this, mars3d_class);
1763
- _this = _callSuper(this, mars3d_class);
1764
- _defineProperty(_this, "type", 'label');
1765
- _defineProperty(_this, "id", null);
1766
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
1767
- _defineProperty(_this, "config", null);
1768
- _defineProperty(_this, "graphic", null);
2649
+ _this = _callSuper(this, mars3d_class, [hnMap]);
2650
+ _this.type = "label";
2651
+ _this.id = null;
2652
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
2653
+ _this.config = null;
2654
+ _this.graphic = null;
1769
2655
  _this.id = option.id;
1770
2656
  deepMerge(_this.option, option);
1771
2657
  _this.config = _this.formatConfig(_this.option);
1772
- if (_this.option.type === 'label') {
2658
+ if (_this.option.type === "label") {
1773
2659
  _this.graphic = new mars3d.graphic.LabelEntity(_this.config);
1774
- } else if (_this.option.type === 'mapLabel') {
2660
+ } else if (_this.option.type === "mapLabel") {
1775
2661
  _this.graphic = new mars3d.graphic.RectangleEntity(_this.config);
1776
2662
  }
1777
2663
  return _this;
@@ -1780,8 +2666,10 @@
1780
2666
  return _createClass(mars3d_class, [{
1781
2667
  key: "formatConfig",
1782
2668
  value: function formatConfig(option) {
1783
- if (option.type === 'label') {
2669
+ if (option.type === "label") {
1784
2670
  var position = new mars3d.LngLatPoint(option.position[0], option.position[1], option.position[2] || 0);
2671
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
2672
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
1785
2673
  return {
1786
2674
  id: option.id,
1787
2675
  position: position,
@@ -1799,14 +2687,14 @@
1799
2687
  scaleByDistance: option.scaleByDistance,
1800
2688
  clampToGround: !option.position[2],
1801
2689
  distanceDisplayCondition: option.distanceDisplayCondition,
1802
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
1803
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
2690
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
2691
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
1804
2692
  background: !!option.background,
1805
2693
  backgroundColor: option.background
1806
2694
  },
1807
2695
  attr: option.data
1808
2696
  };
1809
- } else if (option.type === 'mapLabel') {
2697
+ } else if (option.type === "mapLabel") {
1810
2698
  var p1 = new mars3d.LngLatPoint(option.position[0][0], option.position[0][1]);
1811
2699
  var p2 = new mars3d.LngLatPoint(option.position[1][0], option.position[1][1]);
1812
2700
  return {
@@ -1816,7 +2704,7 @@
1816
2704
  clampToGround: !option.position[0][2],
1817
2705
  materialOptions: {
1818
2706
  text: option.text,
1819
- font_family: '楷体',
2707
+ font_family: "楷体",
1820
2708
  color: option.color,
1821
2709
  font_weight: option.fontWeight,
1822
2710
  font_size: option.fontSize,
@@ -1849,11 +2737,11 @@
1849
2737
  function gaode_class(option) {
1850
2738
  var _this2;
1851
2739
  _classCallCheck(this, gaode_class);
1852
- _this2 = _callSuper(this, gaode_class);
1853
- _defineProperty(_this2, "id", null);
1854
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
1855
- _defineProperty(_this2, "config", null);
1856
- _defineProperty(_this2, "graphic", null);
2740
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
2741
+ _this2.id = null;
2742
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
2743
+ _this2.config = null;
2744
+ _this2.graphic = null;
1857
2745
  _this2.id = option.id;
1858
2746
  deepMerge(_this2.option, option);
1859
2747
  _this2.config = _this2.formatConfig(_this2.option);
@@ -1871,16 +2759,16 @@
1871
2759
  data: option.data
1872
2760
  },
1873
2761
  text: option.text,
1874
- anchor: 'center',
2762
+ anchor: "center",
1875
2763
  // 设置文本标记锚点
1876
2764
  draggable: true,
1877
- cursor: 'pointer',
2765
+ cursor: "pointer",
1878
2766
  style: {
1879
- 'border': 0,
1880
- 'text-align': 'center',
1881
- 'font-size': option.fontSize,
1882
- 'color': option.color,
1883
- 'background-color': option.background
2767
+ border: 0,
2768
+ "text-align": "center",
2769
+ "font-size": option.fontSize,
2770
+ color: option.color,
2771
+ "background-color": option.background
1884
2772
  },
1885
2773
  position: [amapPosition[0], amapPosition[1]],
1886
2774
  offset: option.offset
@@ -1897,9 +2785,162 @@
1897
2785
  }
1898
2786
  }]);
1899
2787
  }(gaode_entity);
2788
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
2789
+ function siji_class(option) {
2790
+ var _this3;
2791
+ _classCallCheck(this, siji_class);
2792
+ _this3 = _callSuper(this, siji_class, [hnMap]);
2793
+ _this3.type = "label";
2794
+ _this3.id = null;
2795
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
2796
+ _this3.config = null;
2797
+ _this3.id = option.id;
2798
+ deepMerge(_this3.option, option);
2799
+ _this3.config = _this3.formatConfig(_this3.option);
2800
+ return _this3;
2801
+ }
2802
+ _inherits(siji_class, _siji_entity);
2803
+ return _createClass(siji_class, [{
2804
+ key: "formatConfig",
2805
+ value: function formatConfig(option) {
2806
+ var config = {};
2807
+ config = {
2808
+ id: option.id,
2809
+ type: "symbol",
2810
+ source: {
2811
+ type: "geojson",
2812
+ data: {
2813
+ type: "FeatureCollection",
2814
+ features: []
2815
+ }
2816
+ },
2817
+ layout: {
2818
+ "text-field": "{name}",
2819
+ "text-size": Number(option.fontSize),
2820
+ "text-anchor": "top",
2821
+ // 顶部对齐
2822
+ "text-offset": this.pixelOffsetToTextOffset(option.offset, option.fontSize),
2823
+ "text-max-width": 8,
2824
+ "text-font": ["Microsoft YaHei Regular"]
2825
+ },
2826
+ // 文本样式
2827
+ paint: {
2828
+ "text-color": option.color,
2829
+ "text-halo-color": option.outlineColor,
2830
+ // 文字外边线颜色
2831
+ "text-halo-width": option.outlineWidth // 文字外边线宽度
2832
+ } // 填充样式
2833
+ };
2834
+ if (option.type === "label") {
2835
+ config.source.data.features[0] = {
2836
+ type: "Feature",
2837
+ geometry: {
2838
+ type: "Point",
2839
+ coordinates: option.position.map(function (num) {
2840
+ return Number(num);
2841
+ })
2842
+ },
2843
+ properties: {
2844
+ name: option.text
2845
+ }
2846
+ };
2847
+ } else if (option.type === "mapLabel") {
2848
+ option.position.forEach(function (item) {
2849
+ config.source.data.features.push({
2850
+ type: "Feature",
2851
+ properties: {
2852
+ name: option.text
2853
+ },
2854
+ geometry: {
2855
+ type: "Point",
2856
+ coordinates: item
2857
+ }
2858
+ });
2859
+ });
2860
+ }
2861
+ return config;
2862
+ }
2863
+ /**
2864
+ * 将 pixelOffset 转换为 text-offset (ems)
2865
+ * @param {Array<number>} pixelOffset - [x, y] 像素偏移
2866
+ * @param {number} textSizePx - 字体大小(px)
2867
+ * @returns {Array<number>} text-offset in ems
2868
+ */
2869
+ }, {
2870
+ key: "pixelOffsetToTextOffset",
2871
+ value: function pixelOffsetToTextOffset(pixelOffset, textSizePx) {
2872
+ return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
2873
+ }
2874
+ }, {
2875
+ key: "set",
2876
+ value: function set(option) {
2877
+ var _this4 = this;
2878
+ deepMerge(this.option, option);
2879
+ this.config = this.formatConfig(this.option);
2880
+ var mySource = hnMap.map.map.getSource(this.config.id);
2881
+ if (this.option.type == "label") {
2882
+ mySource.setData({
2883
+ type: "FeatureCollection",
2884
+ features: [{
2885
+ type: "Feature",
2886
+ properties: {
2887
+ name: this.option.text
2888
+ },
2889
+ geometry: {
2890
+ type: "Point",
2891
+ coordinates: this.option.position.map(function (num) {
2892
+ return Number(num);
2893
+ })
2894
+ }
2895
+ }]
2896
+ });
2897
+ } else if (this.option.type == "mapLabel") {
2898
+ // 构建新的数据源对象
2899
+ var sourceObj = {
2900
+ type: "FeatureCollection",
2901
+ features: this.option.position.map(function (item) {
2902
+ return {
2903
+ type: "Feature",
2904
+ properties: {
2905
+ name: _this4.option.text
2906
+ },
2907
+ geometry: {
2908
+ type: "Point",
2909
+ coordinates: item
2910
+ }
2911
+ };
2912
+ })
2913
+ };
2914
+ // 更新数据源
2915
+ mySource.setData(sourceObj);
2916
+ }
2917
+ for (var key in this.config) {
2918
+ if (this.config.hasOwnProperty(key)) {
2919
+ if (key == "paint") {
2920
+ for (var key2 in this.config[key]) {
2921
+ if (this.config[key].hasOwnProperty(key2)) {
2922
+ // 遍历 paint 属性
2923
+ hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "text-halo-width" ? Number(this.config[key][key2]) : this.config[key][key2]);
2924
+ }
2925
+ }
2926
+ }
2927
+ if (key == "layout") {
2928
+ for (var _key in this.config[key]) {
2929
+ if (this.config[key].hasOwnProperty(_key)) {
2930
+ // 遍历 layout 属性
2931
+ hnMap.map.map.setLayoutProperty(this.config.id, _key, _key === "text-size" ? Number(this.config[key][_key]) : this.config[key][_key]);
2932
+ }
2933
+ }
2934
+ }
2935
+ }
2936
+ }
2937
+ }
2938
+ }]);
2939
+ }(siji_entity);
1900
2940
  var fn = {
1901
2941
  mars3d: mars3d_class,
1902
- gaode: gaode_class
2942
+ gaode: gaode_class,
2943
+ siji: siji_class
1903
2944
  };
1904
2945
  return fn[hnMap.mapType];
1905
2946
  });
@@ -1908,7 +2949,7 @@
1908
2949
  var defaultOption = {
1909
2950
  id: "",
1910
2951
  position: [],
1911
- type: 'line',
2952
+ type: "line",
1912
2953
  color: "#ffffff",
1913
2954
  width: 2,
1914
2955
  opacity: 1,
@@ -1917,13 +2958,13 @@
1917
2958
  outlineWidth: 2,
1918
2959
  dashColor: "#00ff00",
1919
2960
  dashLength: 16,
1920
- image: '',
2961
+ image: "",
1921
2962
  repeat: [1, 1],
1922
2963
  speed: 5,
1923
2964
  scaleByDistance: true,
1924
2965
  distanceDisplayCondition: false,
1925
- distanceDisplayCondition_far: Number.MAX_VALUE,
1926
- distanceDisplayCondition_near: 0,
2966
+ distanceDisplayCondition_far: 1,
2967
+ distanceDisplayCondition_near: 18,
1927
2968
  data: null,
1928
2969
  combine: false,
1929
2970
  instances: []
@@ -1932,12 +2973,13 @@
1932
2973
  function mars3d_class(option) {
1933
2974
  var _this;
1934
2975
  _classCallCheck(this, mars3d_class);
1935
- _this = _callSuper(this, mars3d_class);
1936
- _defineProperty(_this, "type", 'line');
1937
- _defineProperty(_this, "id", null);
1938
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
1939
- _defineProperty(_this, "config", null);
1940
- _defineProperty(_this, "graphic", null);
2976
+ // debugger
2977
+ _this = _callSuper(this, mars3d_class, [hnMap]);
2978
+ _this.type = "line";
2979
+ _this.id = null;
2980
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
2981
+ _this.config = null;
2982
+ _this.graphic = null;
1941
2983
  _this.id = option.id;
1942
2984
  deepMerge(_this.option, option);
1943
2985
  _this.config = _this.formatConfig(_this.option);
@@ -1954,6 +2996,8 @@
1954
2996
  value: function formatConfig(option) {
1955
2997
  var _this2 = this;
1956
2998
  var config = {};
2999
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
3000
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
1957
3001
  if (option.combine) {
1958
3002
  config = {
1959
3003
  id: option.id,
@@ -1969,7 +3013,7 @@
1969
3013
  id: option.id,
1970
3014
  positions: option.position,
1971
3015
  style: {
1972
- materialType: 'Color',
3016
+ materialType: "Color",
1973
3017
  color: option.color,
1974
3018
  width: option.width,
1975
3019
  opacity: option.opacity,
@@ -1979,32 +3023,32 @@
1979
3023
  clampToGround: !option.position[0][2],
1980
3024
  scaleByDistance: option.scaleByDistance,
1981
3025
  distanceDisplayCondition: option.distanceDisplayCondition,
1982
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
1983
- distanceDisplayCondition_near: option.distanceDisplayCondition_near
3026
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
3027
+ distanceDisplayCondition_near: distanceDisplayCondition_near
1984
3028
  },
1985
3029
  attr: option.data
1986
3030
  };
1987
3031
  switch (option.type) {
1988
- case 'line':
1989
- config.style.materialType = 'Color';
3032
+ case "line":
3033
+ config.style.materialType = "Color";
1990
3034
  break;
1991
- case 'dash':
1992
- config.style.materialType = 'PolylineDash';
3035
+ case "dash":
3036
+ config.style.materialType = "PolylineDash";
1993
3037
  config.style.materialOptions = {
1994
3038
  color: option.color,
1995
3039
  gapColor: option.dashColor,
1996
3040
  dashPattern: option.dashPattern
1997
3041
  };
1998
3042
  break;
1999
- case 'flicker':
2000
- config.style.materialType = 'LineFlicker';
3043
+ case "flicker":
3044
+ config.style.materialType = "LineFlicker";
2001
3045
  config.style.materialOptions = {
2002
3046
  color: option.color,
2003
3047
  speed: option.speed
2004
3048
  };
2005
3049
  break;
2006
- case 'flow':
2007
- config.style.materialType = 'LineFlow';
3050
+ case "flow":
3051
+ config.style.materialType = "LineFlow";
2008
3052
  config.style.materialOptions = {
2009
3053
  color: option.color,
2010
3054
  image: option.image,
@@ -2012,8 +3056,8 @@
2012
3056
  speed: option.speed
2013
3057
  };
2014
3058
  break;
2015
- case 'arrow':
2016
- config.style.materialType = 'PolylineArrow';
3059
+ case "arrow":
3060
+ config.style.materialType = "PolylineArrow";
2017
3061
  config.style.materialOptions = {
2018
3062
  color: option.color
2019
3063
  };
@@ -2029,7 +3073,6 @@
2029
3073
  this.config = this.formatConfig(this.option);
2030
3074
  this.graphic.setOptions(this.config);
2031
3075
  }
2032
-
2033
3076
  // flyTo(option = {}) {
2034
3077
  // let config = {}
2035
3078
  // if(option.height){
@@ -2043,13 +3086,12 @@
2043
3086
  value: function openPopup() {
2044
3087
  this.graphic.openPopup();
2045
3088
  }
2046
-
2047
- /**
2048
- * 判断给定的经纬度坐标是否在某个多边形内
2049
- *
2050
- * @param {number} lng - 经度
2051
- * @param {number} lat - 纬度
2052
- * @returns {boolean} 返回一个布尔值,如果给定的坐标在多边形内则为true,否则为false
3089
+ /**
3090
+ * 判断给定的经纬度坐标是否在某个多边形内
3091
+ *
3092
+ * @param {number} lng - 经度
3093
+ * @param {number} lat - 纬度
3094
+ * @returns {boolean} 返回一个布尔值,如果给定的坐标在多边形内则为true,否则为false
2053
3095
  */
2054
3096
  }, {
2055
3097
  key: "isInPoly",
@@ -2062,11 +3104,11 @@
2062
3104
  function gaode_class(option) {
2063
3105
  var _this3;
2064
3106
  _classCallCheck(this, gaode_class);
2065
- _this3 = _callSuper(this, gaode_class);
2066
- _defineProperty(_this3, "id", null);
2067
- _defineProperty(_this3, "option", JSON.parse(JSON.stringify(defaultOption)));
2068
- _defineProperty(_this3, "config", null);
2069
- _defineProperty(_this3, "graphic", null);
3107
+ _this3 = _callSuper(this, gaode_class, [hnMap]);
3108
+ _this3.id = null;
3109
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
3110
+ _this3.config = null;
3111
+ _this3.graphic = null;
2070
3112
  _this3.id = option.id;
2071
3113
  deepMerge(_this3.option, option);
2072
3114
  _this3.config = _this3.formatConfig(_this3.option);
@@ -2092,18 +3134,153 @@
2092
3134
  };
2093
3135
  }
2094
3136
  }, {
2095
- key: "set",
2096
- value: function set(option) {
2097
- deepMerge(this.option, option);
2098
- this.config = this.formatConfig(this.option);
2099
- this.graphic.setOptions(this.config);
2100
- this.graphic.setPath(this.config.path);
3137
+ key: "set",
3138
+ value: function set(option) {
3139
+ deepMerge(this.option, option);
3140
+ this.config = this.formatConfig(this.option);
3141
+ this.graphic.setOptions(this.config);
3142
+ this.graphic.setPath(this.config.path);
3143
+ }
3144
+ }]);
3145
+ }(gaode_entity);
3146
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
3147
+ function siji_class(option) {
3148
+ var _this4;
3149
+ _classCallCheck(this, siji_class);
3150
+ // debugger;
3151
+ _this4 = _callSuper(this, siji_class, [hnMap]);
3152
+ _this4.type = "line";
3153
+ _this4.id = null;
3154
+ _this4.option = JSON.parse(JSON.stringify(defaultOption));
3155
+ _this4.config = null;
3156
+ _this4.graphic = null;
3157
+ _this4.intervalId = null;
3158
+ _this4.id = option.id;
3159
+ deepMerge(_this4.option, option);
3160
+ _this4.config = _this4.formatConfig(_this4.option);
3161
+ // this.graphic = hnMap.map.map.addLayer(this.config);
3162
+ return _this4;
3163
+ }
3164
+ _inherits(siji_class, _siji_entity);
3165
+ return _createClass(siji_class, [{
3166
+ key: "flickers",
3167
+ value: function flickers(speed, isShow) {
3168
+ if (this.intervalId !== null) {
3169
+ clearInterval(this.intervalId);
3170
+ }
3171
+ var opacity = isShow ? 1 : 0;
3172
+ var that = this;
3173
+ this.intervalId = setInterval(function () {
3174
+ isShow = !isShow;
3175
+ opacity = isShow ? 1 : 0;
3176
+ that.config["line-opacity"] = opacity;
3177
+ }, speed);
3178
+ }
3179
+ }, {
3180
+ key: "formatConfig",
3181
+ value: function formatConfig(option) {
3182
+ var config = {};
3183
+ config = {
3184
+ id: option.id,
3185
+ type: "line",
3186
+ source: {
3187
+ type: "geojson",
3188
+ data: {
3189
+ type: "FeatureCollection",
3190
+ features: [{
3191
+ type: "Feature",
3192
+ geometry: {
3193
+ type: "LineString",
3194
+ coordinates: option.position
3195
+ },
3196
+ properties: Object.assign({
3197
+ id: option.id
3198
+ }, option.data)
3199
+ }]
3200
+ }
3201
+ },
3202
+ layout: {
3203
+ "line-cap": "round",
3204
+ "line-join": "round"
3205
+ },
3206
+ paint: {
3207
+ "line-color": option.type == "dash" ? option.dashColor : option.color,
3208
+ "line-width": Number(option.width),
3209
+ "line-opacity": Number(option.opacity)
3210
+ }
3211
+ };
3212
+ var isShow = true;
3213
+ switch (option.type) {
3214
+ case "line":
3215
+ break;
3216
+ case "dash":
3217
+ config.paint["line-dasharray"] = [option.dashLength * 1, option.dashLength * 1];
3218
+ break;
3219
+ case "flicker":
3220
+ this.flickers(option.speed * 1, isShow); // 调用 flickers 方法
3221
+ break;
3222
+ }
3223
+ return config;
3224
+ }
3225
+ }, {
3226
+ key: "set",
3227
+ value: function set(option) {
3228
+ deepMerge(this.option, option);
3229
+ this.config = this.formatConfig(this.option);
3230
+ for (var key in this.config) {
3231
+ if (this.config.hasOwnProperty(key)) {
3232
+ if (key == "paint") {
3233
+ for (var key2 in this.config[key]) {
3234
+ if (this.config[key].hasOwnProperty(key2)) {
3235
+ // 遍历 paint 属性
3236
+ hnMap.map.map.setPaintProperty(this.config.id, key2, key2 == "line-opacity" || key2 == "line-width" ? Number(this.config[key][key2]) : this.config[key][key2]);
3237
+ if (option.type == "dash") {
3238
+ hnMap.map.map.setPaintProperty(this.config.id, "line-dasharray", [option.dashLength, option.dashLength]);
3239
+ }
3240
+ // else {
3241
+ // hnMap.map.map.setPaintProperty(
3242
+ // this.config.id,
3243
+ // "line-dasharray",
3244
+ // [0, 0]
3245
+ // );
3246
+ // }
3247
+ }
3248
+ }
3249
+ }
3250
+ }
3251
+ }
3252
+ }
3253
+ }, {
3254
+ key: "openPopup",
3255
+ value: function openPopup() {
3256
+ this.graphic.openPopup();
3257
+ }
3258
+ /**
3259
+ * 判断给定的经纬度坐标是否在某个多边形内
3260
+ *
3261
+ * @param {number} lng - 经度
3262
+ * @param {number} lat - 纬度
3263
+ * @returns {boolean} 返回一个布尔值,如果给定的坐标在多边形内则为true,否则为false
3264
+ */
3265
+ }, {
3266
+ key: "isInPoly",
3267
+ value: function isInPoly(lng, lat) {
3268
+ return this.graphic.isInPoly(new mars3d.LngLatPoint(lng, lat));
3269
+ }
3270
+ }, {
3271
+ key: "dispose",
3272
+ value: function dispose() {
3273
+ if (this.intervalId) {
3274
+ clearInterval(this.intervalId); // 清除定时器
3275
+ this.intervalId = null; // 重置定时器ID
3276
+ }
2101
3277
  }
2102
3278
  }]);
2103
- }(gaode_entity);
3279
+ }(siji_entity);
2104
3280
  var fn = {
2105
3281
  mars3d: mars3d_class,
2106
- gaode: gaode_class
3282
+ gaode: gaode_class,
3283
+ siji: siji_class
2107
3284
  };
2108
3285
  return fn[hnMap.mapType];
2109
3286
  });
@@ -2112,7 +3289,7 @@
2112
3289
  var defaultOption = {
2113
3290
  id: "",
2114
3291
  position: [],
2115
- type: 'color',
3292
+ type: "color",
2116
3293
  radius: 20,
2117
3294
  color: "#ff0000",
2118
3295
  opacity: 1,
@@ -2126,20 +3303,20 @@
2126
3303
  outlineHighLightTaperPower: 1,
2127
3304
  scaleByDistance: true,
2128
3305
  distanceDisplayCondition: false,
2129
- distanceDisplayCondition_far: Number.MAX_VALUE,
2130
- distanceDisplayCondition_near: 0,
3306
+ distanceDisplayCondition_far: 1,
3307
+ distanceDisplayCondition_near: 18,
2131
3308
  data: null
2132
3309
  };
2133
3310
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
2134
3311
  function mars3d_class(option) {
2135
3312
  var _this;
2136
3313
  _classCallCheck(this, mars3d_class);
2137
- _this = _callSuper(this, mars3d_class);
2138
- _defineProperty(_this, "type", 'circle');
2139
- _defineProperty(_this, "id", null);
2140
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
2141
- _defineProperty(_this, "config", null);
2142
- _defineProperty(_this, "graphic", null);
3314
+ _this = _callSuper(this, mars3d_class, [hnMap]);
3315
+ _this.type = "circle";
3316
+ _this.id = null;
3317
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
3318
+ _this.config = null;
3319
+ _this.graphic = null;
2143
3320
  _this.id = option.id;
2144
3321
  deepMerge(_this.option, option);
2145
3322
  _this.config = _this.formatConfig(_this.option);
@@ -2150,6 +3327,8 @@
2150
3327
  return _createClass(mars3d_class, [{
2151
3328
  key: "formatConfig",
2152
3329
  value: function formatConfig(option) {
3330
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
3331
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
2153
3332
  var config = {
2154
3333
  id: option.id,
2155
3334
  position: new mars3d.LngLatPoint(option.position[0], option.position[1], option.position[2] || 0),
@@ -2163,17 +3342,17 @@
2163
3342
  outlineOpacity: option.outlineOpacity,
2164
3343
  scaleByDistance: option.scaleByDistance,
2165
3344
  distanceDisplayCondition: option.distanceDisplayCondition,
2166
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
2167
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
3345
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
3346
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
2168
3347
  clampToGround: !option.position[2]
2169
3348
  },
2170
3349
  attr: option.data
2171
3350
  };
2172
3351
  switch (option.type) {
2173
- case 'color':
3352
+ case "color":
2174
3353
  config.style.materialType = mars3d.MaterialType.Color;
2175
3354
  break;
2176
- case 'wave':
3355
+ case "wave":
2177
3356
  config.style.materialType = mars3d.MaterialType.CircleWave;
2178
3357
  config.style.materialOptions = {
2179
3358
  color: option.color,
@@ -2201,26 +3380,17 @@
2201
3380
  this.config = this.formatConfig(this.option);
2202
3381
  this.graphic.setOptions(this.config);
2203
3382
  }
2204
-
2205
- // flyTo(option = {}) {
2206
- // let config = {}
2207
- // if(option.height){
2208
- // config.scale = this.calculateScaleFromHeight(this.graphic, option.height)
2209
- // }
2210
- //
2211
- // this.graphic.flyTo(config);
2212
- // }
2213
3383
  }]);
2214
3384
  }(mars3d_entity);
2215
3385
  var gaode_class = /*#__PURE__*/function (_gaode_entity) {
2216
3386
  function gaode_class(option) {
2217
3387
  var _this2;
2218
3388
  _classCallCheck(this, gaode_class);
2219
- _this2 = _callSuper(this, gaode_class);
2220
- _defineProperty(_this2, "id", null);
2221
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
2222
- _defineProperty(_this2, "config", null);
2223
- _defineProperty(_this2, "graphic", null);
3389
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
3390
+ _this2.id = null;
3391
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
3392
+ _this2.config = null;
3393
+ _this2.graphic = null;
2224
3394
  _this2.id = option.id;
2225
3395
  deepMerge(_this2.option, option);
2226
3396
  _this2.config = _this2.formatConfig(_this2.option);
@@ -2256,9 +3426,77 @@
2256
3426
  }
2257
3427
  }]);
2258
3428
  }(gaode_entity);
3429
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
3430
+ function siji_class(option) {
3431
+ var _this3;
3432
+ _classCallCheck(this, siji_class);
3433
+ _this3 = _callSuper(this, siji_class, [hnMap]);
3434
+ _this3.type = "circle";
3435
+ _this3.id = null;
3436
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
3437
+ _this3.config = null;
3438
+ _this3.graphic = null;
3439
+ _this3.id = option.id;
3440
+ deepMerge(_this3.option, option);
3441
+ _this3.config = _this3.formatConfig(_this3.option);
3442
+ _this3.graphic = new SGMap.DrawCircleHandler(_this3.config);
3443
+ return _this3;
3444
+ }
3445
+ _inherits(siji_class, _siji_entity);
3446
+ return _createClass(siji_class, [{
3447
+ key: "formatConfig",
3448
+ value: function formatConfig(option) {
3449
+ var config = {
3450
+ id: option.id,
3451
+ map: hnMap.map.map,
3452
+ // 允许编辑
3453
+ enableEdit: false,
3454
+ // 允许调整圆心
3455
+ canMove: false,
3456
+ // 设置非编辑状态下的图层颜色
3457
+ drawColor: option.outlineColor,
3458
+ // 设置编辑状态下的图层颜色
3459
+ // editColor: "red",
3460
+ style: {
3461
+ // 设置非编辑状态下多边形面的样式
3462
+ polygon: {
3463
+ "fill-color": option.color,
3464
+ // 填充颜色覆盖drawColor设置的颜色,呈现绿色
3465
+ "fill-opacity": Number(option.opacity)
3466
+ }
3467
+ },
3468
+ // 编辑数据
3469
+ featuresList: []
3470
+ };
3471
+ return config;
3472
+ }
3473
+ }, {
3474
+ key: "set",
3475
+ value: function set(option) {
3476
+ deepMerge(this.option, option);
3477
+ this.config = this.formatConfig(this.option);
3478
+ this.graphic.remove();
3479
+ this.graphic.clearData();
3480
+ this.graphic = new SGMap.DrawCircleHandler(this.config);
3481
+ var featureArr = {
3482
+ type: "Feature",
3483
+ properties: {
3484
+ centerPoint: option.position,
3485
+ radius: option.radius
3486
+ },
3487
+ geometry: {
3488
+ type: "Polygon",
3489
+ coordinates: []
3490
+ }
3491
+ };
3492
+ this.graphic.addFeature(featureArr);
3493
+ }
3494
+ }]);
3495
+ }(siji_entity);
2259
3496
  var fn = {
2260
3497
  mars3d: mars3d_class,
2261
- gaode: gaode_class
3498
+ gaode: gaode_class,
3499
+ siji: siji_class
2262
3500
  };
2263
3501
  return fn[hnMap.mapType];
2264
3502
  });
@@ -2275,20 +3513,20 @@
2275
3513
  outlineOpacity: 1,
2276
3514
  scaleByDistance: true,
2277
3515
  distanceDisplayCondition: false,
2278
- distanceDisplayCondition_far: Number.MAX_VALUE,
2279
- distanceDisplayCondition_near: 0,
3516
+ distanceDisplayCondition_far: 1,
3517
+ distanceDisplayCondition_near: 18,
2280
3518
  data: null
2281
3519
  };
2282
3520
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
2283
3521
  function mars3d_class(option) {
2284
3522
  var _this;
2285
3523
  _classCallCheck(this, mars3d_class);
2286
- _this = _callSuper(this, mars3d_class);
2287
- _defineProperty(_this, "type", 'retangle');
2288
- _defineProperty(_this, "id", null);
2289
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
2290
- _defineProperty(_this, "config", null);
2291
- _defineProperty(_this, "graphic", null);
3524
+ _this = _callSuper(this, mars3d_class, [hnMap]);
3525
+ _this.type = "retangle";
3526
+ _this.id = null;
3527
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
3528
+ _this.config = null;
3529
+ _this.graphic = null;
2292
3530
  _this.id = option.id;
2293
3531
  deepMerge(_this.option, option);
2294
3532
  _this.config = _this.formatConfig(_this.option);
@@ -2299,6 +3537,8 @@
2299
3537
  return _createClass(mars3d_class, [{
2300
3538
  key: "formatConfig",
2301
3539
  value: function formatConfig(option) {
3540
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
3541
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
2302
3542
  return {
2303
3543
  id: option.id,
2304
3544
  positions: option.position,
@@ -2311,8 +3551,8 @@
2311
3551
  outlineOpacity: option.outlineOpacity,
2312
3552
  scaleByDistance: option.scaleByDistance,
2313
3553
  distanceDisplayCondition: option.distanceDisplayCondition,
2314
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
2315
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
3554
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
3555
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
2316
3556
  clampToGround: !option.position[0][2]
2317
3557
  },
2318
3558
  attr: option.data
@@ -2331,25 +3571,25 @@
2331
3571
  function gaode_class(option) {
2332
3572
  var _this2;
2333
3573
  _classCallCheck(this, gaode_class);
2334
- _this2 = _callSuper(this, gaode_class);
2335
- _defineProperty(_this2, "id", null);
2336
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
2337
- _defineProperty(_this2, "config", null);
2338
- _defineProperty(_this2, "graphic", null);
3574
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
3575
+ _this2.id = null;
3576
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
3577
+ _this2.config = null;
3578
+ _this2.graphic = null;
2339
3579
  _this2.id = option.id;
2340
3580
  deepMerge(_this2.option, option);
2341
3581
  _this2.config = _this2.formatConfig(_this2.option);
2342
- _this2.graphic = new AMap.Rectangle(_this2.config);
3582
+ _this2.graphic = new AMap.Rectangle(_this2.config); //创建矩形
2343
3583
  return _this2;
2344
3584
  }
2345
3585
  _inherits(gaode_class, _gaode_entity);
2346
3586
  return _createClass(gaode_class, [{
2347
3587
  key: "formatConfig",
2348
3588
  value: function formatConfig(option) {
2349
- var amapPosition = wgs84ToGcj02Format(option.position);
2350
- var southWest = new AMap.LngLat(amapPosition[0][0], amapPosition[0][1]);
2351
- var northEast = new AMap.LngLat(amapPosition[1][0], amapPosition[1][1]);
2352
- var bounds = new AMap.Bounds(southWest, northEast);
3589
+ var amapPosition = wgs84ToGcj02Format(option.position); //坐标转换
3590
+ var southWest = new AMap.LngLat(amapPosition[0][0], amapPosition[0][1]); //
3591
+ var northEast = new AMap.LngLat(amapPosition[1][0], amapPosition[1][1]); //
3592
+ var bounds = new AMap.Bounds(southWest, northEast); // 创建矩形
2353
3593
  return {
2354
3594
  bounds: bounds,
2355
3595
  fillColor: option.color,
@@ -2373,9 +3613,87 @@
2373
3613
  }
2374
3614
  }]);
2375
3615
  }(gaode_entity);
3616
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
3617
+ function siji_class(option) {
3618
+ var _this3;
3619
+ _classCallCheck(this, siji_class);
3620
+ _this3 = _callSuper(this, siji_class, [hnMap]);
3621
+ _this3.type = "rectangle";
3622
+ _this3.id = null;
3623
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
3624
+ _this3.config = null;
3625
+ _this3.graphic = null;
3626
+ _this3.id = option.id;
3627
+ deepMerge(_this3.option, option);
3628
+ _this3.config = _this3.formatConfig(_this3.option);
3629
+ return _this3;
3630
+ }
3631
+ _inherits(siji_class, _siji_entity);
3632
+ return _createClass(siji_class, [{
3633
+ key: "formatConfig",
3634
+ value: function formatConfig(option) {
3635
+ var RectanglePosition = createRectangleCoordinates(option.position[0], option.position[1]);
3636
+ console.log([RectanglePosition], "========RectanglePosition=======");
3637
+ var config = {
3638
+ id: option.id,
3639
+ type: "fill",
3640
+ source: {
3641
+ type: "geojson",
3642
+ data: {
3643
+ type: "FeatureCollection",
3644
+ features: [{
3645
+ type: "Feature",
3646
+ geometry: {
3647
+ type: "Polygon",
3648
+ coordinates: [RectanglePosition]
3649
+ }
3650
+ }]
3651
+ }
3652
+ },
3653
+ paint: {
3654
+ "fill-color": option.color,
3655
+ // 填充颜色覆盖drawColor设置的颜色,呈现绿色
3656
+ "fill-opacity": Number(option.opacity)
3657
+ }
3658
+ };
3659
+ return config;
3660
+ }
3661
+ }, {
3662
+ key: "set",
3663
+ value: function set(option) {
3664
+ deepMerge(this.option, option);
3665
+ this.config = this.formatConfig(this.option);
3666
+ var RectanglePosition = createRectangleCoordinates(option.position[0], option.position[1]);
3667
+ var mySource = hnMap.map.map.getSource(this.config.id);
3668
+ mySource.setData({
3669
+ type: "FeatureCollection",
3670
+ features: [{
3671
+ type: "Feature",
3672
+ geometry: {
3673
+ type: "Polygon",
3674
+ coordinates: [RectanglePosition] //三层数组[[0,0],[0,0]]
3675
+ }
3676
+ }]
3677
+ });
3678
+ for (var key in this.config) {
3679
+ if (this.config.hasOwnProperty(key)) {
3680
+ if (key == "paint") {
3681
+ for (var key2 in this.config[key]) {
3682
+ if (this.config[key].hasOwnProperty(key2)) {
3683
+ // 遍历 paint 属性
3684
+ hnMap.map.map.setPaintProperty(this.config.id, key2, this.config[key][key2]);
3685
+ }
3686
+ }
3687
+ }
3688
+ }
3689
+ }
3690
+ }
3691
+ }]);
3692
+ }(siji_entity);
2376
3693
  var fn = {
2377
3694
  mars3d: mars3d_class,
2378
- gaode: gaode_class
3695
+ gaode: gaode_class,
3696
+ siji: siji_class
2379
3697
  };
2380
3698
  return fn[hnMap.mapType];
2381
3699
  });
@@ -2392,20 +3710,20 @@
2392
3710
  outlineOpacity: 1,
2393
3711
  scaleByDistance: true,
2394
3712
  distanceDisplayCondition: false,
2395
- distanceDisplayCondition_far: Number.MAX_VALUE,
2396
- distanceDisplayCondition_near: 0,
3713
+ distanceDisplayCondition_far: 1,
3714
+ distanceDisplayCondition_near: 18,
2397
3715
  data: null
2398
3716
  };
2399
3717
  var mars3d_class = /*#__PURE__*/function (_mars3d_entity) {
2400
3718
  function mars3d_class(option) {
2401
3719
  var _this;
2402
3720
  _classCallCheck(this, mars3d_class);
2403
- _this = _callSuper(this, mars3d_class);
2404
- _defineProperty(_this, "type", 'polygon');
2405
- _defineProperty(_this, "id", null);
2406
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
2407
- _defineProperty(_this, "config", null);
2408
- _defineProperty(_this, "graphic", null);
3721
+ _this = _callSuper(this, mars3d_class, [hnMap]);
3722
+ _this.type = "polygon";
3723
+ _this.id = null;
3724
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
3725
+ _this.config = null;
3726
+ _this.graphic = null;
2409
3727
  _this.id = option.id;
2410
3728
  deepMerge(_this.option, option);
2411
3729
  _this.config = _this.formatConfig(_this.option);
@@ -2416,6 +3734,8 @@
2416
3734
  return _createClass(mars3d_class, [{
2417
3735
  key: "formatConfig",
2418
3736
  value: function formatConfig(option) {
3737
+ var distanceDisplayCondition_far = getLevelMiddleHeight(option.distanceDisplayCondition_far);
3738
+ var distanceDisplayCondition_near = getLevelMiddleHeight(option.distanceDisplayCondition_near);
2419
3739
  return {
2420
3740
  id: option.id,
2421
3741
  positions: option.position,
@@ -2428,8 +3748,8 @@
2428
3748
  outlineOpacity: option.outlineOpacity,
2429
3749
  scaleByDistance: option.scaleByDistance,
2430
3750
  distanceDisplayCondition: option.distanceDisplayCondition,
2431
- distanceDisplayCondition_far: option.distanceDisplayCondition_far,
2432
- distanceDisplayCondition_near: option.distanceDisplayCondition_near,
3751
+ distanceDisplayCondition_far: distanceDisplayCondition_far,
3752
+ distanceDisplayCondition_near: distanceDisplayCondition_near,
2433
3753
  clampToGround: option.position[0] && !option.position[0][2]
2434
3754
  },
2435
3755
  attr: option.data
@@ -2448,11 +3768,11 @@
2448
3768
  function gaode_class(option) {
2449
3769
  var _this2;
2450
3770
  _classCallCheck(this, gaode_class);
2451
- _this2 = _callSuper(this, gaode_class);
2452
- _defineProperty(_this2, "id", null);
2453
- _defineProperty(_this2, "option", JSON.parse(JSON.stringify(defaultOption)));
2454
- _defineProperty(_this2, "config", null);
2455
- _defineProperty(_this2, "graphic", null);
3771
+ _this2 = _callSuper(this, gaode_class, [hnMap]);
3772
+ _this2.id = null;
3773
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
3774
+ _this2.config = null;
3775
+ _this2.graphic = null;
2456
3776
  _this2.id = option.id;
2457
3777
  deepMerge(_this2.option, option);
2458
3778
  _this2.config = _this2.formatConfig(_this2.option);
@@ -2487,9 +3807,84 @@
2487
3807
  }
2488
3808
  }]);
2489
3809
  }(gaode_entity);
3810
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
3811
+ function siji_class(option) {
3812
+ var _this3;
3813
+ _classCallCheck(this, siji_class);
3814
+ _this3 = _callSuper(this, siji_class, [hnMap]);
3815
+ _this3.type = "polygon";
3816
+ _this3.id = null;
3817
+ _this3.option = JSON.parse(JSON.stringify(defaultOption));
3818
+ _this3.config = null;
3819
+ _this3.graphic = null;
3820
+ _this3.id = option.id;
3821
+ deepMerge(_this3.option, option);
3822
+ _this3.config = _this3.formatConfig(_this3.option);
3823
+ return _this3;
3824
+ }
3825
+ _inherits(siji_class, _siji_entity);
3826
+ return _createClass(siji_class, [{
3827
+ key: "formatConfig",
3828
+ value: function formatConfig(option) {
3829
+ var config = {
3830
+ id: option.id,
3831
+ type: "fill",
3832
+ source: {
3833
+ type: "geojson",
3834
+ data: {
3835
+ type: "FeatureCollection",
3836
+ features: [{
3837
+ type: "Feature",
3838
+ geometry: {
3839
+ type: "Polygon",
3840
+ coordinates: option.position
3841
+ }
3842
+ }]
3843
+ }
3844
+ },
3845
+ paint: {
3846
+ "fill-color": option.color,
3847
+ // 填充颜色覆盖drawColor设置的颜色,呈现绿色
3848
+ "fill-opacity": Number(option.opacity)
3849
+ }
3850
+ };
3851
+ return config;
3852
+ }
3853
+ }, {
3854
+ key: "set",
3855
+ value: function set(option) {
3856
+ deepMerge(this.option, option);
3857
+ this.config = this.formatConfig(this.option);
3858
+ var mySource = hnMap.map.map.getSource(this.config.id);
3859
+ mySource.setData({
3860
+ type: "FeatureCollection",
3861
+ features: [{
3862
+ type: "Feature",
3863
+ geometry: {
3864
+ type: "Polygon",
3865
+ coordinates: [option.position] //三层数组[[[0,0],[0,0]]]
3866
+ }
3867
+ }]
3868
+ });
3869
+ for (var key in this.config) {
3870
+ if (this.config.hasOwnProperty(key)) {
3871
+ if (key == "paint") {
3872
+ for (var key2 in this.config[key]) {
3873
+ if (this.config[key].hasOwnProperty(key2)) {
3874
+ // 遍历 paint 属性
3875
+ hnMap.map.map.setPaintProperty(this.config.id, key2, this.config[key][key2]);
3876
+ }
3877
+ }
3878
+ }
3879
+ }
3880
+ }
3881
+ }
3882
+ }]);
3883
+ }(siji_entity);
2490
3884
  var fn = {
2491
3885
  mars3d: mars3d_class,
2492
- gaode: gaode_class
3886
+ gaode: gaode_class,
3887
+ siji: siji_class
2493
3888
  };
2494
3889
  return fn[hnMap.mapType];
2495
3890
  });
@@ -2499,14 +3894,15 @@
2499
3894
  id: "",
2500
3895
  position: [],
2501
3896
  speed: 10,
2502
- loop: false,
3897
+ replaySpeed: 20,
3898
+ clockLoop: false,
2503
3899
  image: {
2504
- src: null,
3900
+ src: "",
2505
3901
  width: 10,
2506
3902
  height: 10
2507
3903
  },
2508
3904
  camera: {
2509
- type: '',
3905
+ type: "",
2510
3906
  pitch: -30,
2511
3907
  radius: 500
2512
3908
  },
@@ -2517,16 +3913,32 @@
2517
3913
  path: {
2518
3914
  color: "#ff0000",
2519
3915
  width: 2
3916
+ },
3917
+ label: {
3918
+ text: "",
3919
+ // 文本内容
3920
+ font_size: 16,
3921
+ color: "#ffffff",
3922
+ outline: false,
3923
+ outlineColor: "#000000",
3924
+ outlineWidth: 1,
3925
+ outlineOpacity: 1,
3926
+ // 描边透明度
3927
+ horizontalOrigin: "left",
3928
+ // 水平对齐方式
3929
+ verticalOrigin: "bottom",
3930
+ // 垂直对齐方式
3931
+ pixelOffset: [0, 0]
2520
3932
  }
2521
3933
  };
2522
3934
  var mars3d_class = /*#__PURE__*/function () {
2523
3935
  function mars3d_class(option) {
2524
3936
  _classCallCheck(this, mars3d_class);
2525
- _defineProperty(this, "type", 'route');
2526
- _defineProperty(this, "id", null);
2527
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
2528
- _defineProperty(this, "config", null);
2529
- _defineProperty(this, "graphic", null);
3937
+ this.type = "route";
3938
+ this.id = null;
3939
+ this.option = JSON.parse(JSON.stringify(defaultOption));
3940
+ this.config = null;
3941
+ this.graphic = null;
2530
3942
  this.id = option.id;
2531
3943
  deepMerge(this.option, option);
2532
3944
  this.config = this.formatConfig(this.option);
@@ -2539,10 +3951,12 @@
2539
3951
  id: option.id,
2540
3952
  speed: option.speed,
2541
3953
  positions: option.position,
2542
- clockLoop: option.loop,
3954
+ // leadTime: option.leadTime,
3955
+ clockLoop: option.clockLoop,
2543
3956
  // 是否循环播放
2544
3957
  camera: {
2545
3958
  type: option.camera.type,
3959
+ // 轨迹类型
2546
3960
  pitch: option.camera.pitch,
2547
3961
  radius: option.camera.radius
2548
3962
  },
@@ -2551,6 +3965,7 @@
2551
3965
  width: option.image.width,
2552
3966
  height: option.image.height
2553
3967
  },
3968
+ // Marker
2554
3969
  polyline: {
2555
3970
  color: option.polyline.color,
2556
3971
  width: option.polyline.width
@@ -2559,8 +3974,31 @@
2559
3974
  path: {
2560
3975
  color: option.path.color,
2561
3976
  width: option.path.width
2562
- // leadTime: 0,
2563
- }
3977
+ },
3978
+ // 轨迹
3979
+ label: {
3980
+ text: option.label.text,
3981
+ // 文本内容
3982
+ font_size: option.label.textSize,
3983
+ color: option.label.color,
3984
+ outline: option.label.outline,
3985
+ outlineColor: option.label.outLineColor,
3986
+ outlineWidth: option.label.outlineWidth,
3987
+ outlineOpacity: option.label.outlineOpacity,
3988
+ // 描边透明度
3989
+ horizontalOrigin: option.label.horizontalOrigin,
3990
+ // 水平对齐方式
3991
+ verticalOrigin: option.label.verticalOrigin,
3992
+ // 垂直对齐方式
3993
+ pixelOffset: option.label.pixelOffset
3994
+ },
3995
+ // model: {
3996
+ // url: option.models.url, // 模型地址
3997
+ // scale: option.models.scale, // 模型缩放比例
3998
+ // minimumPixelSize: option.models.minimumPixelSize, // 模型最小尺寸
3999
+ // clampToGround: option.models.clampToGround, // 模型贴地
4000
+ // },
4001
+ attr: option.data
2564
4002
  };
2565
4003
  }
2566
4004
  }, {
@@ -2605,18 +4043,20 @@
2605
4043
  var gaode_class = /*#__PURE__*/function () {
2606
4044
  function gaode_class(option) {
2607
4045
  _classCallCheck(this, gaode_class);
2608
- _defineProperty(this, "id", null);
2609
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
2610
- _defineProperty(this, "config_graphic", null);
2611
- _defineProperty(this, "config_path", null);
2612
- _defineProperty(this, "graphic", null);
4046
+ this.id = null;
4047
+ this.option = JSON.parse(JSON.stringify(defaultOption));
4048
+ this.config_graphic = null;
4049
+ this.config_path = null;
4050
+ this.graphic = null;
4051
+ this.pathLayer = null;
4052
+ this.path = null;
2613
4053
  this.id = option.id;
2614
4054
  deepMerge(this.option, option);
2615
4055
  this.config_graphic = this.formatConfigGraphic(this.option);
2616
4056
  this.config_path = this.formatConfigPath(this.option);
2617
4057
  this.graphic = new AMap.Marker(this.config_graphic);
2618
4058
  this.addPath();
2619
- this.graphic.on('moving', function (e) {
4059
+ this.graphic.on("moving", function (e) {
2620
4060
  hnMap.map.map.setCenter(e.target.getPosition(), true);
2621
4061
  });
2622
4062
  hnMap.map.map.setFitView();
@@ -2643,12 +4083,12 @@
2643
4083
  value: function formatConfigPath(option) {
2644
4084
  var amapPosition = wgs84ToGcj02Format(option.position);
2645
4085
  return {
2646
- id: option.id + '_path',
4086
+ id: option.id + "_path",
2647
4087
  position: amapPosition,
2648
4088
  width: option.polyline.width,
2649
4089
  color: option.polyline.color,
2650
4090
  data: {
2651
- id: option.id + '_path'
4091
+ id: option.id + "_path"
2652
4092
  }
2653
4093
  };
2654
4094
  }
@@ -2665,7 +4105,7 @@
2665
4105
  key: "addPath",
2666
4106
  value: function addPath() {
2667
4107
  this.pathLayer = hnMap.map.addLayer(new hnMap.Layer({
2668
- id: this.id + '_path_layer'
4108
+ id: this.id + "_path_layer"
2669
4109
  }));
2670
4110
  if (this.pathLayer) {
2671
4111
  this.path = new hnMap.Line(this.config_path);
@@ -2680,7 +4120,7 @@
2680
4120
  var t1 = turf.point(prev);
2681
4121
  var t2 = turf.point(next);
2682
4122
  var distance = turf.distance(t1, t2, {
2683
- units: 'meters'
4123
+ units: "meters"
2684
4124
  });
2685
4125
  _this.graphic.moveAlong(_this.path.graphic._opts.path, {
2686
4126
  duration: Number(distance / _this.config_graphic.speed).toFixed(0),
@@ -2722,9 +4162,199 @@
2722
4162
  }
2723
4163
  }]);
2724
4164
  }();
4165
+ var siji_class = /*#__PURE__*/function (_siji_entity) {
4166
+ // timer: any = null;
4167
+ function siji_class(option) {
4168
+ var _this2;
4169
+ _classCallCheck(this, siji_class);
4170
+ _this2 = _callSuper(this, siji_class, [hnMap]);
4171
+ _this2.type = "route";
4172
+ _this2.id = null;
4173
+ _this2.option = JSON.parse(JSON.stringify(defaultOption));
4174
+ _this2.config_routeline = null;
4175
+ _this2.config_routeplay = null;
4176
+ _this2.imgMarker = null;
4177
+ _this2.chunkData = null;
4178
+ _this2.id = option.id;
4179
+ deepMerge(_this2.option, option);
4180
+ _this2.config_routeline = _this2.formatConfig(_this2.option);
4181
+ _this2.config_routeplay = _this2.formatConfigPlay(_this2.option);
4182
+ return _this2;
4183
+ }
4184
+ _inherits(siji_class, _siji_entity);
4185
+ return _createClass(siji_class, [{
4186
+ key: "formatConfig",
4187
+ value: function formatConfig(option) {
4188
+ return {
4189
+ id: "route-line_" + option.id,
4190
+ type: "line",
4191
+ source: {
4192
+ type: "geojson",
4193
+ data: {
4194
+ geometry: {
4195
+ type: "LineString",
4196
+ coordinates: option.position
4197
+ },
4198
+ properties: {},
4199
+ type: "Feature"
4200
+ }
4201
+ },
4202
+ layout: {
4203
+ "line-join": "round",
4204
+ "line-cap": "round"
4205
+ },
4206
+ paint: {
4207
+ "line-color": option.polyline.color,
4208
+ "line-width": Number(option.polyline.width)
4209
+ }
4210
+ };
4211
+ }
4212
+ }, {
4213
+ key: "formatConfigPlay",
4214
+ value: function formatConfigPlay(option) {
4215
+ return {
4216
+ id: "route-played_" + option.id,
4217
+ type: "line",
4218
+ source: {
4219
+ type: "geojson",
4220
+ data: {
4221
+ type: "FeatureCollection",
4222
+ features: []
4223
+ }
4224
+ },
4225
+ layout: {
4226
+ "line-join": "round",
4227
+ "line-cap": "round"
4228
+ },
4229
+ paint: {
4230
+ "line-color": option.path.color,
4231
+ "line-width": Number(option.path.width)
4232
+ }
4233
+ };
4234
+ }
4235
+ }, {
4236
+ key: "createCar",
4237
+ value: function createCar() {
4238
+ if (this.imgMarker) {
4239
+ this.imgMarker.remove();
4240
+ }
4241
+ // 画marker点
4242
+ var el = document.createElement("img");
4243
+ el.src = this.option.image.src;
4244
+ el.style.width = this.option.image.width + "px";
4245
+ el.style.height = this.option.image.height + "px";
4246
+ this.imgMarker = new SGMap.Marker(el).setLngLat(this.config_routeline.source.data.geometry.coordinates[0]).addTo(hnMap.map.map);
4247
+ }
4248
+ }, {
4249
+ key: "joinLinePoint",
4250
+ value: function joinLinePoint() {
4251
+ // 播放速度,这里选择20倍播放速度
4252
+ var replaySpeed = 20;
4253
+ // 按照实际车辆跑的速度,每秒跑 60 / 3600 km
4254
+ // 车辆位置按每秒刷新20帧算,1/20秒移动的距离为 60 / 3600 / 20 km
4255
+ var step = 60 / 3600 / 20;
4256
+ // 倍数播放时,每帧移动的步长为 step * replaySpeed
4257
+ var scaleSpeed = step * replaySpeed;
4258
+ // 线路根据步长scaleSpeed间隔进行插值,插值线总长/步长(distance/scaleSpeed)个点,得到chunkData
4259
+ // 注意:线路长度一定,scaleSpeed越小,插值数量越多。线路长度很长的情况下,请调整replaySpeed,避免插值点数过多产生卡顿
4260
+ this.chunkData = turf.lineChunk(this.config_routeline.source.data, scaleSpeed, {
4261
+ units: "kilometers"
4262
+ });
4263
+ return this.chunkData;
4264
+ }
4265
+ }, {
4266
+ key: "start",
4267
+ value: function start() {
4268
+ var _this3 = this;
4269
+ var features = this.chunkData.features;
4270
+ var max = features.length;
4271
+ var order = 0;
4272
+ var timer = setInterval(function () {
4273
+ order++;
4274
+ if (order >= max) {
4275
+ clearInterval(timer);
4276
+ } else {
4277
+ var beforePoint = features[order - 1].geometry.coordinates[1];
4278
+ var nowPoint = features[order].geometry.coordinates[1];
4279
+ // 设置小车的位置
4280
+ _this3.imgMarker.setLngLat(nowPoint);
4281
+ // 设置小车的方向
4282
+ var bearing = turf.bearing(turf.point(beforePoint), turf.point(nowPoint));
4283
+ bearing && _this3.imgMarker.setRotation(bearing - 90);
4284
+ // 更新已走过的线路图层数据
4285
+ _this3.readerReplayedRouterLayer(order, _this3.option);
4286
+ }
4287
+ }, 1000 / 20); // 间隔1000 / 20执行一次,每秒执行20次,可以和上面计算线路的时间间隔配合
4288
+ }
4289
+ }, {
4290
+ key: "readerReplayedRouterLayer",
4291
+ value: function readerReplayedRouterLayer(order, option) {
4292
+ hnMap.map.map.getSource("route-played_" + option.id).setData({
4293
+ type: "FeatureCollection",
4294
+ features: this.chunkData.features.slice(0, order + 1)
4295
+ });
4296
+ }
4297
+ }, {
4298
+ key: "set",
4299
+ value: function set(option) {
4300
+ deepMerge(this.option, option);
4301
+ if (this.imgMarker) {
4302
+ this.imgMarker.remove();
4303
+ }
4304
+ this.createCar();
4305
+ this.config_routeline = this.formatConfig(this.option);
4306
+ var mySource_routeline = hnMap.map.map.getSource(this.config_routeline.id);
4307
+ mySource_routeline.setData({
4308
+ geometry: {
4309
+ type: "LineString",
4310
+ coordinates: option.position
4311
+ },
4312
+ properties: option.data,
4313
+ type: "Feature"
4314
+ });
4315
+ for (var key in this.config_routeline) {
4316
+ if (this.config_routeline.hasOwnProperty(key)) {
4317
+ if (key == "paint") {
4318
+ for (var key2 in this.config_routeline[key]) {
4319
+ if (this.config_routeline[key].hasOwnProperty(key2)) {
4320
+ // 遍历 paint 属性
4321
+ hnMap.map.map.setPaintProperty(this.config_routeline.id, key2, this.config_routeline[key][key2]);
4322
+ }
4323
+ }
4324
+ }
4325
+ }
4326
+ }
4327
+ this.config_routeplay = this.formatConfigPlay(this.option);
4328
+ var mySource_routeplay = hnMap.map.map.getSource(this.config_routeplay.id);
4329
+ mySource_routeplay.setData({
4330
+ geometry: {
4331
+ type: "LineString",
4332
+ coordinates: option.position
4333
+ },
4334
+ properties: option.data,
4335
+ type: "Feature"
4336
+ });
4337
+ for (var _key in this.config_routeplay) {
4338
+ if (this.config_routeplay.hasOwnProperty(_key)) {
4339
+ if (_key == "paint") {
4340
+ for (var _key2 in this.config_routeplay[_key]) {
4341
+ if (this.config_routeplay[_key].hasOwnProperty(_key2)) {
4342
+ // 遍历 paint 属性
4343
+ hnMap.map.map.setPaintProperty(this.config_routeplay.id, _key2, this.config_routeplay[_key][_key2]);
4344
+ }
4345
+ }
4346
+ }
4347
+ }
4348
+ }
4349
+ this.joinLinePoint();
4350
+ this.start();
4351
+ }
4352
+ }]);
4353
+ }(siji_entity);
2725
4354
  var fn = {
2726
4355
  mars3d: mars3d_class,
2727
- gaode: gaode_class
4356
+ gaode: gaode_class,
4357
+ siji: siji_class
2728
4358
  };
2729
4359
  return fn[hnMap.mapType];
2730
4360
  });
@@ -2749,11 +4379,11 @@
2749
4379
  var mars3d_class = /*#__PURE__*/function () {
2750
4380
  function mars3d_class(option) {
2751
4381
  _classCallCheck(this, mars3d_class);
2752
- _defineProperty(this, "type", 'heatMap');
2753
- _defineProperty(this, "id", null);
2754
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
2755
- _defineProperty(this, "config", null);
2756
- _defineProperty(this, "layerEntity", null);
4382
+ this.type = 'heatMap';
4383
+ this.id = null;
4384
+ this.option = JSON.parse(JSON.stringify(defaultOption));
4385
+ this.config = null;
4386
+ this.layerEntity = null;
2757
4387
  this.id = option.id;
2758
4388
  deepMerge(this.option, option);
2759
4389
  this.config = this.formatConfig(this.option);
@@ -2833,10 +4463,10 @@
2833
4463
  var gaode_class = /*#__PURE__*/function () {
2834
4464
  function gaode_class(option) {
2835
4465
  _classCallCheck(this, gaode_class);
2836
- _defineProperty(this, "id", null);
2837
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
2838
- _defineProperty(this, "config", null);
2839
- _defineProperty(this, "layerEntity", null);
4466
+ this.id = null;
4467
+ this.option = JSON.parse(JSON.stringify(defaultOption));
4468
+ this.config = null;
4469
+ this.layerEntity = null;
2840
4470
  this.id = option.id;
2841
4471
  deepMerge(this.option, option);
2842
4472
  this.config = this.formatConfig(this.option);
@@ -2926,13 +4556,13 @@
2926
4556
  var _this;
2927
4557
  _classCallCheck(this, mars3d_class);
2928
4558
  _this = _callSuper(this, mars3d_class, [option]);
2929
- _defineProperty(_this, "type", 'cluster');
2930
- _defineProperty(_this, "id", null);
2931
- _defineProperty(_this, "option", JSON.parse(JSON.stringify(defaultOption)));
2932
- _defineProperty(_this, "config_layer", null);
2933
- _defineProperty(_this, "config_label", null);
2934
- _defineProperty(_this, "children", null);
2935
- _defineProperty(_this, "layerEntity", null);
4559
+ _this.type = 'cluster';
4560
+ _this.id = null;
4561
+ _this.option = JSON.parse(JSON.stringify(defaultOption));
4562
+ _this.config_layer = null;
4563
+ _this.config_label = null;
4564
+ _this.children = null;
4565
+ _this.layerEntity = null;
2936
4566
  _this.id = option.id;
2937
4567
  _this.children = [];
2938
4568
  deepMerge(_this.option, option);
@@ -2941,7 +4571,6 @@
2941
4571
  _this.layerEntity = new mars3d.layer.GraphicLayer(_this.config_layer);
2942
4572
  return _this;
2943
4573
  }
2944
-
2945
4574
  // 格式化layer配置
2946
4575
  _inherits(mars3d_class, _Layer);
2947
4576
  return _createClass(mars3d_class, [{
@@ -2955,7 +4584,6 @@
2955
4584
  }
2956
4585
  };
2957
4586
  }
2958
-
2959
4587
  // 格式化点位配置
2960
4588
  }, {
2961
4589
  key: "formatConfigLabel",
@@ -3007,7 +4635,6 @@
3007
4635
  return v.id !== _this3.id;
3008
4636
  });
3009
4637
  }
3010
-
3011
4638
  // 添加属性弹窗
3012
4639
  }, {
3013
4640
  key: "addPopupByAttr",
@@ -3021,13 +4648,13 @@
3021
4648
  });
3022
4649
  });
3023
4650
  }
3024
-
3025
4651
  // 添加自定义dom弹窗
3026
4652
  }, {
3027
4653
  key: "addCustomPopup",
3028
4654
  value: function addCustomPopup(getCustomDom) {
3029
- this.layerEntity.bindPopup(/*#__PURE__*/function () {
3030
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
4655
+ var _this4 = this;
4656
+ this.layerEntity.bindPopup(function (event) {
4657
+ return __awaiter(_this4, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
3031
4658
  var data;
3032
4659
  return _regenerator().w(function (_context) {
3033
4660
  while (1) switch (_context.n) {
@@ -3046,10 +4673,7 @@
3046
4673
  }
3047
4674
  }, _callee);
3048
4675
  }));
3049
- return function (_x) {
3050
- return _ref.apply(this, arguments);
3051
- };
3052
- }(), {
4676
+ }, {
3053
4677
  offsetY: -20
3054
4678
  });
3055
4679
  }
@@ -3074,7 +4698,6 @@
3074
4698
  }
3075
4699
  return entity;
3076
4700
  }
3077
-
3078
4701
  // 手动打开聚合功能
3079
4702
  }, {
3080
4703
  key: "openCluster",
@@ -3085,7 +4708,6 @@
3085
4708
  this.config_layer = this.formatConfigLayer(this.option);
3086
4709
  this.layerEntity.clusterEnabled = true;
3087
4710
  }
3088
-
3089
4711
  // 手动关闭聚合功能
3090
4712
  }, {
3091
4713
  key: "closeCluster",
@@ -3097,16 +4719,16 @@
3097
4719
  this.layerEntity.clusterEnabled = false;
3098
4720
  }
3099
4721
  }]);
3100
- }(layer);
4722
+ }(layer(hnMap));
3101
4723
  var gaode_class = /*#__PURE__*/function () {
3102
4724
  function gaode_class(option) {
3103
4725
  _classCallCheck(this, gaode_class);
3104
- _defineProperty(this, "id", null);
3105
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
3106
- _defineProperty(this, "config", null);
3107
- _defineProperty(this, "layerEntity", null);
4726
+ this.id = null;
4727
+ this.option = JSON.parse(JSON.stringify(defaultOption));
4728
+ this.config = null;
4729
+ this.layerEntity = null;
3108
4730
  // 创建全局信息窗口实例
3109
- _defineProperty(this, "infoWindow", null);
4731
+ this.infoWindow = null;
3110
4732
  this.id = option.id;
3111
4733
  deepMerge(this.option, option);
3112
4734
  this.config = this.formatConfig(this.option);
@@ -3115,13 +4737,13 @@
3115
4737
  return _createClass(gaode_class, [{
3116
4738
  key: "formatConfig",
3117
4739
  value: function formatConfig(option) {
3118
- var _this4 = this;
4740
+ var _this5 = this;
3119
4741
  var position = option.position.map(function (item, index) {
3120
4742
  return {
3121
4743
  lnglat: wgs84ToGcj02Format(item),
3122
4744
  // 添加弹窗属性参数
3123
4745
  extData: {
3124
- id: _this4.id + '_point' + index
4746
+ id: _this5.id + '_point' + index
3125
4747
  }
3126
4748
  };
3127
4749
  });
@@ -3150,9 +4772,9 @@
3150
4772
  };
3151
4773
  var _renderMarker = function _renderMarker(context) {
3152
4774
  var icon = new AMap.Icon({
3153
- image: _this4.option.style.image,
3154
- imageSize: new AMap.Size(_this4.option.style.height, _this4.option.style.width),
3155
- size: new AMap.Size(_this4.option.style.height, _this4.option.style.width)
4775
+ image: _this5.option.style.image,
4776
+ imageSize: new AMap.Size(_this5.option.style.height, _this5.option.style.width),
4777
+ size: new AMap.Size(_this5.option.style.height, _this5.option.style.width)
3156
4778
  });
3157
4779
  context.marker.setIcon(icon);
3158
4780
  };
@@ -3179,10 +4801,10 @@
3179
4801
  }, {
3180
4802
  key: "destroy",
3181
4803
  value: function destroy() {
3182
- var _this5 = this;
4804
+ var _this6 = this;
3183
4805
  this.layerEntity.setMap(null);
3184
4806
  hnMap.map.layerList = hnMap.map.layerList.filter(function (v) {
3185
- return v.id !== _this5.id;
4807
+ return v.id !== _this6.id;
3186
4808
  });
3187
4809
  }
3188
4810
  }, {
@@ -3198,12 +4820,11 @@
3198
4820
  var centerLat = totalLat / this.config.position.length;
3199
4821
  hnMap.map.map.setCenter([centerLng, centerLat]);
3200
4822
  }
3201
-
3202
4823
  // 添加属性弹窗
3203
4824
  }, {
3204
4825
  key: "addPopupByAttr",
3205
4826
  value: function addPopupByAttr() {
3206
- var _this6 = this;
4827
+ var _this7 = this;
3207
4828
  if (!this.infoWindow) {
3208
4829
  this.infoWindow = new AMap.InfoWindow({
3209
4830
  offset: new AMap.Pixel(0, -30)
@@ -3216,17 +4837,16 @@
3216
4837
  for (var key in data) {
3217
4838
  content += "<div>".concat(key, ": ").concat(data[key], "</div>");
3218
4839
  }
3219
- _this6.infoWindow.setContent(content);
3220
- _this6.infoWindow.open(hnMap.map.map, cluster.marker._position);
4840
+ _this7.infoWindow.setContent(content);
4841
+ _this7.infoWindow.open(hnMap.map.map, cluster.marker._position);
3221
4842
  }
3222
4843
  });
3223
4844
  }
3224
-
3225
4845
  // 添加自定义dom弹窗
3226
4846
  }, {
3227
4847
  key: "addCustomPopup",
3228
4848
  value: function addCustomPopup(getCustomDom) {
3229
- var _this7 = this;
4849
+ var _this8 = this;
3230
4850
  if (!this.infoWindow) {
3231
4851
  this.infoWindow = new AMap.InfoWindow({
3232
4852
  offset: new AMap.Pixel(0, -30)
@@ -3236,8 +4856,8 @@
3236
4856
  if (cluster.clusterData.length === 1) {
3237
4857
  var data = cluster.clusterData[0].extData;
3238
4858
  var dom = getCustomDom(data);
3239
- _this7.infoWindow.setContent(dom);
3240
- _this7.infoWindow.open(hnMap.map.map, cluster.marker._position);
4859
+ _this8.infoWindow.setContent(dom);
4860
+ _this8.infoWindow.open(hnMap.map.map, cluster.marker._position);
3241
4861
  }
3242
4862
  });
3243
4863
  }
@@ -3262,11 +4882,11 @@
3262
4882
  var mars3d_class = /*#__PURE__*/function () {
3263
4883
  function mars3d_class(option) {
3264
4884
  _classCallCheck(this, mars3d_class);
3265
- _defineProperty(this, "type", 'pointCloud');
3266
- _defineProperty(this, "id", null);
3267
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
3268
- _defineProperty(this, "config", null);
3269
- _defineProperty(this, "layerEntity", null);
4885
+ this.type = 'pointCloud';
4886
+ this.id = null;
4887
+ this.option = JSON.parse(JSON.stringify(defaultOption));
4888
+ this.config = null;
4889
+ this.layerEntity = null;
3270
4890
  this.id = option.id;
3271
4891
  deepMerge(this.option, option);
3272
4892
  this.config = this.formatConfig(this.option);
@@ -3303,7 +4923,6 @@
3303
4923
  return v.id !== _this.id;
3304
4924
  });
3305
4925
  }
3306
-
3307
4926
  // 添加属性弹窗
3308
4927
  }, {
3309
4928
  key: "addPopupByAttr",
@@ -3370,11 +4989,11 @@
3370
4989
  var mars3d_class = /*#__PURE__*/function () {
3371
4990
  function mars3d_class(option) {
3372
4991
  _classCallCheck(this, mars3d_class);
3373
- _defineProperty(this, "type", 'geoJson');
3374
- _defineProperty(this, "id", null);
3375
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
3376
- _defineProperty(this, "config", null);
3377
- _defineProperty(this, "layerEntity", null);
4992
+ this.type = 'geoJson';
4993
+ this.id = null;
4994
+ this.option = JSON.parse(JSON.stringify(defaultOption));
4995
+ this.config = null;
4996
+ this.layerEntity = null;
3378
4997
  this.id = option.id;
3379
4998
  deepMerge(this.option, option);
3380
4999
  this.config = this.formatConfig(this.option);
@@ -3447,7 +5066,6 @@
3447
5066
  value: function flyTo() {
3448
5067
  this.layerEntity.flyTo();
3449
5068
  }
3450
-
3451
5069
  // 添加属性弹窗
3452
5070
  }, {
3453
5071
  key: "addPopupByAttr",
@@ -3463,13 +5081,13 @@
3463
5081
  }
3464
5082
  });
3465
5083
  }
3466
-
3467
5084
  // 添加自定义dom弹窗
3468
5085
  }, {
3469
5086
  key: "addCustomPopup",
3470
5087
  value: function addCustomPopup(getCustomDom) {
3471
- this.layerEntity.bindPopup(/*#__PURE__*/function () {
3472
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
5088
+ var _this2 = this;
5089
+ this.layerEntity.bindPopup(function (event) {
5090
+ return __awaiter(_this2, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
3473
5091
  var data;
3474
5092
  return _regenerator().w(function (_context) {
3475
5093
  while (1) switch (_context.n) {
@@ -3488,10 +5106,7 @@
3488
5106
  }
3489
5107
  }, _callee);
3490
5108
  }));
3491
- return function (_x) {
3492
- return _ref.apply(this, arguments);
3493
- };
3494
- }(), {
5109
+ }, {
3495
5110
  offsetY: -20
3496
5111
  });
3497
5112
  }
@@ -3500,10 +5115,10 @@
3500
5115
  var gaode_class = /*#__PURE__*/function () {
3501
5116
  function gaode_class(option) {
3502
5117
  _classCallCheck(this, gaode_class);
3503
- _defineProperty(this, "id", null);
3504
- _defineProperty(this, "option", JSON.parse(JSON.stringify(defaultOption)));
3505
- _defineProperty(this, "config", null);
3506
- _defineProperty(this, "layerEntity", null);
5118
+ this.id = null;
5119
+ this.option = JSON.parse(JSON.stringify(defaultOption));
5120
+ this.config = null;
5121
+ this.layerEntity = null;
3507
5122
  this.id = option.id;
3508
5123
  deepMerge(this.option, option);
3509
5124
  this.config = this.formatConfig(this.option);
@@ -3532,10 +5147,10 @@
3532
5147
  }, {
3533
5148
  key: "destroy",
3534
5149
  value: function destroy() {
3535
- var _this2 = this;
5150
+ var _this3 = this;
3536
5151
  this.layerEntity.setMap(null);
3537
5152
  hnMap.map.layerList = hnMap.map.layerList.filter(function (v) {
3538
- return v.id !== _this2.id;
5153
+ return v.id !== _this3.id;
3539
5154
  });
3540
5155
  }
3541
5156
  }, {
@@ -3550,124 +5165,212 @@
3550
5165
  return fn[hnMap.mapType];
3551
5166
  });
3552
5167
 
3553
- var hnMap = /*#__PURE__*/function () {
3554
- function hnMap(id, option, mapType) {
3555
- _classCallCheck(this, hnMap);
3556
- _defineProperty(this, "id", null);
3557
- _defineProperty(this, "option", null);
3558
- _defineProperty(this, "mapType", null);
3559
- if (!hnMap.allowConstruction) {
3560
- throw new Error('此构造方法不允许直接调用,请调用create方法进行实例化');
5168
+ var HnMap = /*#__PURE__*/function () {
5169
+ /**
5170
+ * HnMap类的构造函数
5171
+ * @param id 地图容器的ID
5172
+ * @param option 地图的配置选项
5173
+ * @param mapType 地图的类型
5174
+ * @param map
5175
+ */
5176
+ function HnMap(id, option, mapType, map) {
5177
+ _classCallCheck(this, HnMap);
5178
+ this.id = null;
5179
+ this.option = null;
5180
+ this.mapType = null;
5181
+ this.map = null;
5182
+ this.Layer = null;
5183
+ this.Point = null;
5184
+ this.NumPoint = null;
5185
+ this.ImagePoint = null;
5186
+ this.DivPoint = null;
5187
+ this.Label = null;
5188
+ this.Line = null;
5189
+ this.Circle = null;
5190
+ this.Rectangle = null;
5191
+ this.Polygon = null;
5192
+ this.Route = null;
5193
+ this.HeatMap = null;
5194
+ this.Cluster = null;
5195
+ this.PointCloud = null;
5196
+ this.GeoJson = null;
5197
+ if (!HnMap.allowConstruction) {
5198
+ throw new Error("请使用 HnMap.create() 创建实例");
3561
5199
  }
3562
5200
  this.id = id;
3563
5201
  this.option = option;
3564
- // 地图类型
3565
5202
  this.mapType = mapType;
3566
-
3567
- // 获取及创建地图对象
3568
- var Map = map(this);
3569
- this.map = new Map(this.id, this.option);
3570
- this.Layer = layer(this);
3571
-
3572
- // 添加地图矢量图形类
3573
- this.Point = point(this);
3574
- this.NumPoint = numPoint(this);
3575
- this.ImagePoint = imagePoint(this);
3576
- this.DivPoint = divPoint(this);
3577
- this.Label = label(this);
3578
- this.Line = line(this);
3579
- this.Circle = circle(this);
3580
- this.Rectangle = rectangle(this);
3581
- this.Polygon = polygon(this);
3582
- this.Route = route(this);
3583
- this.HeatMap = heatMap(this);
3584
- this.Cluster = cluster(this);
3585
- this.PointCloud = pointCloud(this);
3586
- this.GeoJson = geoJson(this);
5203
+ this.map = map; // ✅ 此时 map 已创建
3587
5204
  }
3588
- return _createClass(hnMap, null, [{
5205
+ /**
5206
+ * 创建HnMap实例的方法
5207
+ * @param id 地图容器的ID
5208
+ * @param option 地图的配置选项
5209
+ * @param mapType 地图的类型
5210
+ */
5211
+ return _createClass(HnMap, [{
5212
+ key: "initModules",
5213
+ value:
5214
+ // ✅ 添加一个初始化方法,用于注册所有图形类
5215
+ function initModules() {
5216
+ this.Layer = layer(this);
5217
+ this.Point = point(this);
5218
+ this.NumPoint = numPoint(this);
5219
+ this.ImagePoint = imagePoint(this);
5220
+ this.DivPoint = divPoint(this);
5221
+ this.Label = label(this);
5222
+ this.Line = line(this);
5223
+ this.Circle = circle(this);
5224
+ this.Rectangle = rectangle(this);
5225
+ this.Polygon = polygon(this);
5226
+ this.Route = route(this);
5227
+ this.HeatMap = heatMap(this);
5228
+ this.Cluster = cluster(this);
5229
+ this.PointCloud = pointCloud(this);
5230
+ this.GeoJson = geoJson(this);
5231
+ }
5232
+ }], [{
3589
5233
  key: "create",
3590
- value: function () {
3591
- var _create = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(id, option, mapType) {
3592
- var currentScriptUrl, _t;
5234
+ value: function create(id, option, mapType) {
5235
+ return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
5236
+ var basePath, MapClass, innerMap, instance, _t;
3593
5237
  return _regenerator().w(function (_context) {
3594
- while (1) switch (_context.n) {
5238
+ while (1) switch (_context.p = _context.n) {
3595
5239
  case 0:
3596
- hnMap.allowConstruction = true;
5240
+ // 判断是否在子路径下
5241
+ basePath = window.location.pathname.endsWith("/") ? window.location.pathname : window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
5242
+ _context.n = 1;
5243
+ return loadResource(basePath + "lib/turf/turf.min.js", "js");
5244
+ case 1:
3597
5245
  _t = mapType;
3598
- _context.n = _t === 'mars3d' ? 1 : _t === 'gaode' ? 9 : _t === 'siji' ? 13 : 14;
5246
+ _context.n = _t === "mars3d" ? 2 : _t === "gaode" ? 9 : _t === "siji" ? 13 : 17;
3599
5247
  break;
3600
- case 1:
3601
- currentScriptUrl = new URL((typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || new URL('index.js', document.baseURI).href))).origin;
3602
- _context.n = 2;
3603
- return loadResource(currentScriptUrl + '/lib/Cesium/Widgets/widgets.css', 'css');
3604
5248
  case 2:
3605
5249
  _context.n = 3;
3606
- return loadResource(currentScriptUrl + '/lib/Cesium/Cesium.js', 'js');
5250
+ return loadResource(basePath + "lib/Cesium/Widgets/widgets.css", "css");
3607
5251
  case 3:
3608
5252
  _context.n = 4;
3609
- return loadResource(currentScriptUrl + '/lib/turf/turf.min.js', 'js');
5253
+ return loadResource(basePath + "lib/Cesium/Cesium.js", "js");
3610
5254
  case 4:
3611
5255
  _context.n = 5;
3612
- return loadResource(currentScriptUrl + '/lib/mars3d/mars3d.css', 'css');
5256
+ return loadResource(basePath + "lib/mars3d/mars3d.css", "css");
3613
5257
  case 5:
3614
5258
  _context.n = 6;
3615
- return loadResource(currentScriptUrl + '/lib/mars3d/mars3d.js', 'js');
5259
+ return loadResource(basePath + "lib/mars3d/mars3d.js", "js");
3616
5260
  case 6:
3617
5261
  _context.n = 7;
3618
- return loadResource(currentScriptUrl + '/lib/mars3d/plugins/heatmap/heatmap.js', 'js');
5262
+ return loadResource(basePath + "lib/mars3d/plugins/heatmap/heatmap.js", "js");
3619
5263
  case 7:
3620
5264
  _context.n = 8;
3621
- return loadResource(currentScriptUrl + '/lib/mars3d/plugins/heatmap/mars3d-heatmap.js', 'js');
5265
+ return loadResource(basePath + "lib/mars3d/plugins/heatmap/mars3d-heatmap.js", "js");
3622
5266
  case 8:
3623
- return _context.a(3, 14);
5267
+ return _context.a(3, 17);
3624
5268
  case 9:
3625
5269
  _context.n = 10;
3626
- return loadResource("https://webapi.amap.com/maps?v=2.0&key=".concat(option.gaode_key, "&plugin=AMap.HeatMap,AMap.MarkerCluster,AMap.MoveAnimation"), 'js');
5270
+ return loadResource("https://webapi.amap.com/maps?v=2.0&key=".concat(option.gaode_key, "&plugin=AMap.HeatMap,AMap.MarkerCluster,AMap.MoveAnimation"), "js");
3627
5271
  case 10:
3628
5272
  _context.n = 11;
3629
- return loadResource('https://a.amap.com/jsapi_demos/static/data3d/lib/three.117.js', 'js');
5273
+ return loadResource("https://a.amap.com/jsapi_demos/static/data3d/lib/three.117.js", "js");
3630
5274
  case 11:
3631
5275
  _context.n = 12;
3632
- return loadResource('https://a.amap.com/jsapi_demos/static/data3d/lib/GLTFLoader.117.min.js', 'js');
5276
+ return loadResource("https://a.amap.com/jsapi_demos/static/data3d/lib/GLTFLoader.117.min.js", "js");
3633
5277
  case 12:
3634
- return _context.a(3, 14);
5278
+ return _context.a(3, 17);
3635
5279
  case 13:
3636
5280
  _context.n = 14;
3637
- return loadResource('https://map.sgcc.com.cn/maps?v=3.0.0', 'js');
5281
+ return loadResource(option.sj_js_url, "js");
3638
5282
  case 14:
3639
- return _context.a(2, new hnMap(id, option, mapType));
5283
+ _context.n = 15;
5284
+ return SGMap.tokenTask.login(option.sj_app_key, option.sj_app_secret);
5285
+ case 15:
5286
+ _context.n = 16;
5287
+ return SGMap.plugin(["SGMap.DrawPolygonHandler", "SGMap.DrawCircleHandler", "SGMap.DrawRectangleHandler", "SGMap.GeocodingTask"]);
5288
+ case 16:
5289
+ return _context.a(3, 17);
5290
+ case 17:
5291
+ // 2. 创建地图对象
5292
+ MapClass = map({
5293
+ id: id,
5294
+ option: option,
5295
+ mapType: mapType
5296
+ }); // 假设 map 是一个工厂
5297
+ _context.n = 18;
5298
+ return MapClass.create(id, option);
5299
+ case 18:
5300
+ innerMap = _context.v;
5301
+ // 真正的地图实例
5302
+ // 3. 创建 HnMap 实例(此时传入 map)
5303
+ HnMap.allowConstruction = true;
5304
+ _context.p = 19;
5305
+ instance = new HnMap(id, option, mapType, innerMap); // 4. ✅ 此时 this.map 已存在,再初始化所有模块
5306
+ instance.initModules();
5307
+ return _context.a(2, instance);
5308
+ case 20:
5309
+ _context.p = 20;
5310
+ HnMap.allowConstruction = false;
5311
+ return _context.f(20);
5312
+ case 21:
5313
+ return _context.a(2);
3640
5314
  }
3641
- }, _callee);
5315
+ }, _callee, null, [[19,, 20, 21]]);
3642
5316
  }));
3643
- function create(_x, _x2, _x3) {
3644
- return _create.apply(this, arguments);
3645
- }
3646
- return create;
3647
- }()
5317
+ }
3648
5318
  }]);
3649
- }();
3650
- // 允许构造函数
3651
- _defineProperty(hnMap, "allowConstruction", false);
5319
+ }(); // 允许构造函数
5320
+ HnMap.allowConstruction = false;
5321
+ /**
5322
+ * 检查资源是否已加载
5323
+ * @param path 资源的路径
5324
+ * @returns {boolean} 资源是否已加载
5325
+ */
5326
+ var isResourceLoaded = function isResourceLoaded(path) {
5327
+ // 检查脚本
5328
+ var scripts = Array.from(document.getElementsByTagName("script"));
5329
+ if (scripts.some(function (script) {
5330
+ return script.src.includes(path);
5331
+ })) {
5332
+ return true;
5333
+ }
5334
+ // 检查样式
5335
+ var links = Array.from(document.getElementsByTagName("link"));
5336
+ return links.some(function (link) {
5337
+ return link.href.includes(path);
5338
+ });
5339
+ };
5340
+ /**
5341
+ * 加载资源的方法
5342
+ * @param path 资源的路径
5343
+ * @param type 资源的类型,'css'或'js'
5344
+ * @returns {Promise<void>} 加载完成的Promise
5345
+ */
3652
5346
  var loadResource = function loadResource(path, type) {
3653
5347
  return new Promise(function (resolve, reject) {
3654
- if (type === 'css') {
3655
- var link = document.createElement('link');
3656
- link.rel = 'stylesheet';
5348
+ // 如果资源已加载,直接返回
5349
+ if (isResourceLoaded(path)) {
5350
+ resolve();
5351
+ return;
5352
+ }
5353
+ if (type === "css") {
5354
+ var link = document.createElement("link");
5355
+ link.rel = "stylesheet";
3657
5356
  link.href = path;
3658
- link.onload = resolve;
5357
+ link.onload = function () {
5358
+ return resolve();
5359
+ };
3659
5360
  link.onerror = reject;
3660
5361
  document.head.appendChild(link);
3661
5362
  } else {
3662
- var script = document.createElement('script');
5363
+ var script = document.createElement("script");
3663
5364
  script.src = path;
3664
- script.onload = resolve;
5365
+ script.onload = function () {
5366
+ return resolve();
5367
+ };
3665
5368
  script.onerror = reject;
3666
5369
  document.body.appendChild(script);
3667
5370
  }
3668
5371
  });
3669
5372
  };
3670
5373
 
3671
- return hnMap;
5374
+ return HnMap;
3672
5375
 
3673
5376
  }));