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