hn-map 1.1.7 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +344 -71
- package/package.json +1 -1
- package/src/base/mars3d_entity.ts +0 -1
- package/src/base/siji_entity.ts +0 -1
- package/src/graphic/imagePoint.ts +1 -4
- package/src/graphic/line.ts +0 -1
- package/src/graphic/point.ts +0 -1
- package/src/index.ts +64 -31
- package/src/layer/heatMap.ts +310 -160
- package/src/layer/layer.ts +24 -8
- package/src/layer/pointCloud.ts +224 -78
- package/src/map.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -933,7 +933,6 @@
|
|
|
933
933
|
value: function updateMapParams(e) {
|
|
934
934
|
this.level = this.map.getZoom();
|
|
935
935
|
var viewPos = this.getExtent();
|
|
936
|
-
console.log("当前缩放级别level:", this.level);
|
|
937
936
|
if (this.level !== this.option.level) {
|
|
938
937
|
this.layerList.forEach(function (layer) {
|
|
939
938
|
layer.children.forEach(function (entity) {
|
|
@@ -1041,9 +1040,13 @@
|
|
|
1041
1040
|
console.error("已存在同名图形" + entity.id);
|
|
1042
1041
|
} else {
|
|
1043
1042
|
this.children.push(entity);
|
|
1044
|
-
this.layerEntity.addGraphic(entity.graphic); // 添加图形
|
|
1045
1043
|
if (entity.type == "route") {
|
|
1044
|
+
this.layerEntity.addGraphic(entity.graphic); // 添加图形
|
|
1046
1045
|
entity.start();
|
|
1046
|
+
} else if (entity.type == "pointCloud" || entity.type == "heatMap") {
|
|
1047
|
+
hnMap.map.map.addLayer(entity.layerEntity);
|
|
1048
|
+
} else {
|
|
1049
|
+
this.layerEntity.addGraphic(entity.graphic); // 添加图形
|
|
1047
1050
|
}
|
|
1048
1051
|
}
|
|
1049
1052
|
}
|
|
@@ -1051,12 +1054,15 @@
|
|
|
1051
1054
|
key: "removeEntity",
|
|
1052
1055
|
value: function removeEntity(entityParam) {
|
|
1053
1056
|
var entity = this.getEntity(entityParam);
|
|
1054
|
-
console.log("removeEntity", entity);
|
|
1055
1057
|
if (entity) {
|
|
1056
1058
|
this.children = this.children.filter(function (v) {
|
|
1057
1059
|
return v.id !== entity.id;
|
|
1058
1060
|
});
|
|
1059
|
-
|
|
1061
|
+
if (entity.type === "pointCloud" || entity.type === "heatMap") {
|
|
1062
|
+
alert(entity.id);
|
|
1063
|
+
hnMap.map.map.removeLayer(entity.id);
|
|
1064
|
+
// entity.id.destroy();
|
|
1065
|
+
}
|
|
1060
1066
|
this.layerEntity.removeGraphic(entity.graphic);
|
|
1061
1067
|
}
|
|
1062
1068
|
}
|
|
@@ -1130,7 +1136,6 @@
|
|
|
1130
1136
|
key: "addPopupByAttr",
|
|
1131
1137
|
value: function addPopupByAttr() {
|
|
1132
1138
|
this.layerEntity.bindPopup(function (event) {
|
|
1133
|
-
console.log(event.graphic, "====event.graphic==");
|
|
1134
1139
|
if (event.graphic.attr) {
|
|
1135
1140
|
var data = event.graphic.attr;
|
|
1136
1141
|
return mars3d.Util.getTemplateHtml({
|
|
@@ -1330,7 +1335,6 @@
|
|
|
1330
1335
|
}, {
|
|
1331
1336
|
key: "updateEntity",
|
|
1332
1337
|
value: function updateEntity(entity, viewPos) {
|
|
1333
|
-
console.log("updateEntity", entity, viewPos);
|
|
1334
1338
|
var isUpdateEntity = hnMap.map.level >= Number(entity.option.distanceDisplayCondition_far) && hnMap.map.level <= Number(entity.option.distanceDisplayCondition_near);
|
|
1335
1339
|
if (isUpdateEntity) {
|
|
1336
1340
|
if (!entity.show && this.isIncludesLabel(entity.option.position, viewPos)) {
|
|
@@ -1385,7 +1389,6 @@
|
|
|
1385
1389
|
key: "addLevelEntity",
|
|
1386
1390
|
value: function addLevelEntity(entity) {
|
|
1387
1391
|
if (entity.type == "imagePoint") {
|
|
1388
|
-
console.log("addLevelEntity=====", entity);
|
|
1389
1392
|
hnMap.map.map.loadImage(entity.option.image, function (error, image) {
|
|
1390
1393
|
entity.config.layout["icon-size"] = entity.option.width / image.width;
|
|
1391
1394
|
entity.config.layout["icon-offset"] = [entity.option.offset[0] / entity.config.layout["icon-size"], entity.option.offset[1] / entity.config.layout["icon-size"]];
|
|
@@ -1417,6 +1420,16 @@
|
|
|
1417
1420
|
entity.createCar();
|
|
1418
1421
|
entity.chunkData = entity.joinLinePoint();
|
|
1419
1422
|
entity.start();
|
|
1423
|
+
} else if (entity.type == "pointCloud") {
|
|
1424
|
+
hnMap.map.map.addLayer(entity.config);
|
|
1425
|
+
} else if (entity.type == "heatMap") {
|
|
1426
|
+
hnMap.map.map.addLayer(entity.config_heatmap);
|
|
1427
|
+
hnMap.map.map.addLayer(entity.config_point);
|
|
1428
|
+
hnMap.map.map.flyTo({
|
|
1429
|
+
center: [entity.option.position[0].lng, entity.option.position[0].lat],
|
|
1430
|
+
duration: 2000,
|
|
1431
|
+
essential: true
|
|
1432
|
+
});
|
|
1420
1433
|
} else {
|
|
1421
1434
|
hnMap.map.map.addLayer(entity.config);
|
|
1422
1435
|
}
|
|
@@ -1459,7 +1472,6 @@
|
|
|
1459
1472
|
value: function moveEntity(layerIds) {
|
|
1460
1473
|
// 数组转字符串
|
|
1461
1474
|
var s = layerIds.join(",");
|
|
1462
|
-
console.log("s===", s);
|
|
1463
1475
|
hnMap.map.map.moveLayer(s);
|
|
1464
1476
|
}
|
|
1465
1477
|
}, {
|
|
@@ -1501,7 +1513,6 @@
|
|
|
1501
1513
|
content += "<div>".concat(key, ": ").concat(data[key], "</div>");
|
|
1502
1514
|
}
|
|
1503
1515
|
_this8.infoWindow.setHTML(content);
|
|
1504
|
-
console.log("e.lngLat===", e.lngLat);
|
|
1505
1516
|
_this8.infoWindow.setLngLat(e.lngLat).addTo(hnMap.map.map);
|
|
1506
1517
|
};
|
|
1507
1518
|
hnMap.map.map.on("click", this.config.id, handleClick);
|
|
@@ -1604,7 +1615,6 @@
|
|
|
1604
1615
|
}, {
|
|
1605
1616
|
key: "destroy",
|
|
1606
1617
|
value: function destroy() {
|
|
1607
|
-
console.log(this.graphic, "=====this.graphic===");
|
|
1608
1618
|
this.graphic.destroy();
|
|
1609
1619
|
}
|
|
1610
1620
|
}, {
|
|
@@ -1773,7 +1783,6 @@
|
|
|
1773
1783
|
value: function flyTo() {
|
|
1774
1784
|
var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1775
1785
|
deepMerge(this.option, option);
|
|
1776
|
-
console.log(this.option, "=====flyTo");
|
|
1777
1786
|
var zoom = this.hnMap.map.map.getZoom();
|
|
1778
1787
|
var center;
|
|
1779
1788
|
if (this.option.center) {
|
|
@@ -2031,7 +2040,6 @@
|
|
|
2031
2040
|
}, {
|
|
2032
2041
|
key: "set",
|
|
2033
2042
|
value: function set(option) {
|
|
2034
|
-
console.log("=====set point====", option);
|
|
2035
2043
|
deepMerge(this.option, option);
|
|
2036
2044
|
this.config = this.formatConfig(this.option);
|
|
2037
2045
|
var mySource = hnMap.map.map.getSource(this.config.id);
|
|
@@ -2546,8 +2554,8 @@
|
|
|
2546
2554
|
// 文本
|
|
2547
2555
|
"text-size": Number(option.fontSize),
|
|
2548
2556
|
"text-anchor": option.verticalOrigin,
|
|
2549
|
-
"icon-anchor": option.verticalOrigin
|
|
2550
|
-
|
|
2557
|
+
"icon-anchor": option.verticalOrigin,
|
|
2558
|
+
"text-offset": convertPosition(option.offset)
|
|
2551
2559
|
},
|
|
2552
2560
|
paint: {
|
|
2553
2561
|
"text-color": option.color
|
|
@@ -2560,10 +2568,7 @@
|
|
|
2560
2568
|
value: function set(option) {
|
|
2561
2569
|
deepMerge(this.option, option);
|
|
2562
2570
|
this.config = this.formatConfig(this.option);
|
|
2563
|
-
console.log(this.config, "======CONFIG=====");
|
|
2564
|
-
console.log(this.option, "=========OPTION");
|
|
2565
2571
|
var mySource = hnMap.map.map.getSource(this.config.id);
|
|
2566
|
-
console.log(mySource, "=========SOURCE");
|
|
2567
2572
|
mySource.setData({
|
|
2568
2573
|
type: "FeatureCollection",
|
|
2569
2574
|
features: [{
|
|
@@ -3210,7 +3215,6 @@
|
|
|
3210
3215
|
// if(option.height){
|
|
3211
3216
|
// config.scale = this.calculateScaleFromHeight(this.graphic, option.height)
|
|
3212
3217
|
// }
|
|
3213
|
-
// console.log(config)
|
|
3214
3218
|
// this.graphic.flyTo(config);
|
|
3215
3219
|
// }
|
|
3216
3220
|
}, {
|
|
@@ -4536,7 +4540,7 @@
|
|
|
4536
4540
|
var mars3d_class = /*#__PURE__*/function () {
|
|
4537
4541
|
function mars3d_class(option) {
|
|
4538
4542
|
_classCallCheck(this, mars3d_class);
|
|
4539
|
-
this.type =
|
|
4543
|
+
this.type = "heatMap";
|
|
4540
4544
|
this.id = null;
|
|
4541
4545
|
this.option = JSON.parse(JSON.stringify(defaultOption));
|
|
4542
4546
|
this.config = null;
|
|
@@ -4568,6 +4572,7 @@
|
|
|
4568
4572
|
clampToGround: option.clampToGround
|
|
4569
4573
|
},
|
|
4570
4574
|
redrawZoom: true,
|
|
4575
|
+
flyTo: true,
|
|
4571
4576
|
attr: option.data
|
|
4572
4577
|
};
|
|
4573
4578
|
}
|
|
@@ -4690,9 +4695,124 @@
|
|
|
4690
4695
|
}
|
|
4691
4696
|
}]);
|
|
4692
4697
|
}();
|
|
4698
|
+
var siji_class = /*#__PURE__*/function () {
|
|
4699
|
+
function siji_class(option) {
|
|
4700
|
+
_classCallCheck(this, siji_class);
|
|
4701
|
+
this.type = "heatMap";
|
|
4702
|
+
this.id = null;
|
|
4703
|
+
this.option = JSON.parse(JSON.stringify(defaultOption));
|
|
4704
|
+
this.config_heatmap = null;
|
|
4705
|
+
this.config_point = null;
|
|
4706
|
+
this.layerEntity = null;
|
|
4707
|
+
this.id = option.id;
|
|
4708
|
+
deepMerge(this.option, option);
|
|
4709
|
+
hnMap.map.map.addSource("themeData", {
|
|
4710
|
+
type: "geojson",
|
|
4711
|
+
data: {
|
|
4712
|
+
type: "FeatureCollection",
|
|
4713
|
+
features: this.option.position.map(function (v) {
|
|
4714
|
+
return {
|
|
4715
|
+
type: "Feature",
|
|
4716
|
+
geometry: {
|
|
4717
|
+
type: "Point",
|
|
4718
|
+
coordinates: [v.lng, v.lat]
|
|
4719
|
+
},
|
|
4720
|
+
properties: {
|
|
4721
|
+
value: v.value
|
|
4722
|
+
}
|
|
4723
|
+
};
|
|
4724
|
+
})
|
|
4725
|
+
}
|
|
4726
|
+
});
|
|
4727
|
+
this.config_heatmap = this.formatConfig_heatmap(this.option);
|
|
4728
|
+
this.config_point = this.formatConfig_point(this.option);
|
|
4729
|
+
}
|
|
4730
|
+
return _createClass(siji_class, [{
|
|
4731
|
+
key: "formatConfig_heatmap",
|
|
4732
|
+
value: function formatConfig_heatmap(option) {
|
|
4733
|
+
var config = {};
|
|
4734
|
+
config = {
|
|
4735
|
+
id: option.id,
|
|
4736
|
+
type: "heatmap",
|
|
4737
|
+
source: "themeData",
|
|
4738
|
+
maxzoom: 17,
|
|
4739
|
+
paint: {
|
|
4740
|
+
/**
|
|
4741
|
+
* 数据点的影响力,weight=10的点相当于十个weight=1的点
|
|
4742
|
+
* 下述为插值表达式,输入是点geojson的properties的mag,输出随mag线性增大
|
|
4743
|
+
*/
|
|
4744
|
+
"heatmap-weight": ["interpolate", ["linear"], ["get", "value"], 0, 0, 150, 1.5],
|
|
4745
|
+
/**
|
|
4746
|
+
* 热力图强度,类似heatmap-weight
|
|
4747
|
+
* 下述为插值表达式,输出随zoom线性变化,zoom为0时值为1,zoom为12时值为3
|
|
4748
|
+
*/
|
|
4749
|
+
"heatmap-intensity": ["interpolate", ["linear"], ["zoom"], 0, 1, 17, 1],
|
|
4750
|
+
/**
|
|
4751
|
+
* 像素的颜色,必须以heatmap-density(热力图像素的密度)为输入
|
|
4752
|
+
* 下述为插值表达式,输出随heatmap-density变化而变化
|
|
4753
|
+
*/
|
|
4754
|
+
"heatmap-color": ["interpolate", ["linear"], ["heatmap-density"], 0, "rgba(255, 0, 0, 0)", 0.4, option.gradient["0.4"], 0.6, option.gradient["0.6"], 0.8, option.gradient["0.8"], 0.9, option.gradient["0.9"]
|
|
4755
|
+
// 0,
|
|
4756
|
+
// "rgba(255, 0, 0, 0)",
|
|
4757
|
+
// 0.1,
|
|
4758
|
+
// option.gradient["0.4"], // "rgba(0, 30, 255, .6)",
|
|
4759
|
+
// 0.2,
|
|
4760
|
+
// "rgba(7, 208, 255, .6)",
|
|
4761
|
+
// 0.3,
|
|
4762
|
+
// option.gradient["0.6"], //"#2cc946",
|
|
4763
|
+
// 0.4,
|
|
4764
|
+
// "#d5fb0c",
|
|
4765
|
+
// 0.5,
|
|
4766
|
+
// option.gradient["0.8"], //"#e04e4e",
|
|
4767
|
+
// 0.6,
|
|
4768
|
+
// option.gradient["0.9"], //"#f33900",
|
|
4769
|
+
// 0.9,
|
|
4770
|
+
// "rgba(243, 57, 0, .6)",
|
|
4771
|
+
// 1,
|
|
4772
|
+
// "rgba(243, 57, 0, .8)",
|
|
4773
|
+
],
|
|
4774
|
+
/**
|
|
4775
|
+
* 该值越大,热力图越平滑,信息越不详细。
|
|
4776
|
+
* 下述为插值表达式,输出随zoom线性变化,zoom为0时值为8,zoom为9时值为20
|
|
4777
|
+
*/
|
|
4778
|
+
"heatmap-radius": ["interpolate", ["linear"], ["zoom"], 0, 5, 17, 50],
|
|
4779
|
+
/**
|
|
4780
|
+
* 透明度,输出为1则不透明
|
|
4781
|
+
* 下述为插值表达式,输出随zoom线性变化,zoom为5时值为0.8,zoom为12时值为0.4
|
|
4782
|
+
*/
|
|
4783
|
+
"heatmap-opacity": ["interpolate", ["linear"], ["zoom"], 5, option.maxOpacity,
|
|
4784
|
+
//0.8,
|
|
4785
|
+
17, option.minOpacity // 0.8
|
|
4786
|
+
]
|
|
4787
|
+
}
|
|
4788
|
+
};
|
|
4789
|
+
return config;
|
|
4790
|
+
}
|
|
4791
|
+
}, {
|
|
4792
|
+
key: "formatConfig_point",
|
|
4793
|
+
value: function formatConfig_point(option) {
|
|
4794
|
+
var config_point = {};
|
|
4795
|
+
config_point = {
|
|
4796
|
+
id: "earthquakes-point",
|
|
4797
|
+
type: "circle",
|
|
4798
|
+
source: "themeData",
|
|
4799
|
+
minzoom: 17,
|
|
4800
|
+
paint: {
|
|
4801
|
+
"circle-radius": ["interpolate", ["linear"], ["zoom"], 5, 1, 20, 12],
|
|
4802
|
+
"circle-color": "rgb(255, 148, 0)",
|
|
4803
|
+
"circle-stroke-color": "white",
|
|
4804
|
+
"circle-stroke-width": 1,
|
|
4805
|
+
"circle-opacity": ["interpolate", ["linear"], ["zoom"], 9, 0, 20, 1]
|
|
4806
|
+
}
|
|
4807
|
+
};
|
|
4808
|
+
return config_point;
|
|
4809
|
+
}
|
|
4810
|
+
}]);
|
|
4811
|
+
}();
|
|
4693
4812
|
var fn = {
|
|
4694
4813
|
mars3d: mars3d_class,
|
|
4695
|
-
gaode: gaode_class
|
|
4814
|
+
gaode: gaode_class,
|
|
4815
|
+
siji: siji_class
|
|
4696
4816
|
};
|
|
4697
4817
|
return fn[hnMap.mapType];
|
|
4698
4818
|
});
|
|
@@ -5039,7 +5159,7 @@
|
|
|
5039
5159
|
var mars3d_class = /*#__PURE__*/function () {
|
|
5040
5160
|
function mars3d_class(option) {
|
|
5041
5161
|
_classCallCheck(this, mars3d_class);
|
|
5042
|
-
this.type =
|
|
5162
|
+
this.type = "pointCloud";
|
|
5043
5163
|
this.id = null;
|
|
5044
5164
|
this.option = JSON.parse(JSON.stringify(defaultOption));
|
|
5045
5165
|
this.config = null;
|
|
@@ -5106,9 +5226,112 @@
|
|
|
5106
5226
|
_classCallCheck(this, gaode_class);
|
|
5107
5227
|
throw new Error("高德地图不支持点云功能");
|
|
5108
5228
|
});
|
|
5229
|
+
var siji_class = /*#__PURE__*/function () {
|
|
5230
|
+
function siji_class(option) {
|
|
5231
|
+
_classCallCheck(this, siji_class);
|
|
5232
|
+
this.type = "pointCloud";
|
|
5233
|
+
this.id = null;
|
|
5234
|
+
this.option = JSON.parse(JSON.stringify(defaultOption));
|
|
5235
|
+
this.config = null;
|
|
5236
|
+
this.layerEntity = null;
|
|
5237
|
+
this.THREE = null;
|
|
5238
|
+
this.camera = null;
|
|
5239
|
+
this.scene = null;
|
|
5240
|
+
this.renderer = null;
|
|
5241
|
+
this.modelTransform = null;
|
|
5242
|
+
this.id = option.id;
|
|
5243
|
+
deepMerge(this.option, option);
|
|
5244
|
+
this.config = this.formatConfig(this.option);
|
|
5245
|
+
}
|
|
5246
|
+
// 传入角度值(0-360度),转换为弧度
|
|
5247
|
+
return _createClass(siji_class, [{
|
|
5248
|
+
key: "calculateRotationFromDegrees",
|
|
5249
|
+
value: function calculateRotationFromDegrees(angleInDegrees) {
|
|
5250
|
+
// 将角度转换为弧度,Three.js中Z轴旋转是顺时针的
|
|
5251
|
+
var rotateZ = angleInDegrees * Math.PI / 180;
|
|
5252
|
+
return [0, 0, rotateZ];
|
|
5253
|
+
}
|
|
5254
|
+
}, {
|
|
5255
|
+
key: "formatConfig",
|
|
5256
|
+
value: function formatConfig(option) {
|
|
5257
|
+
var modelOrigin = convertPosition([option.position.lng, option.position.lat]);
|
|
5258
|
+
var modelAltitude = option.position.alt;
|
|
5259
|
+
var modelRotate = this.calculateRotationFromDegrees(option.rotation);
|
|
5260
|
+
var modelScale = option.scale * 1e-6;
|
|
5261
|
+
var modelTransform = {
|
|
5262
|
+
translateX: SGMap.MercatorCoordinate.fromLngLat(modelOrigin, modelAltitude).x,
|
|
5263
|
+
translateY: SGMap.MercatorCoordinate.fromLngLat(modelOrigin, modelAltitude).y,
|
|
5264
|
+
translateZ: SGMap.MercatorCoordinate.fromLngLat(modelOrigin, modelAltitude).z,
|
|
5265
|
+
rotateX: modelRotate[0],
|
|
5266
|
+
rotateY: modelRotate[1],
|
|
5267
|
+
rotateZ: modelRotate[2],
|
|
5268
|
+
scale: modelScale
|
|
5269
|
+
};
|
|
5270
|
+
var THREE = window.THREE;
|
|
5271
|
+
var config = {};
|
|
5272
|
+
config = {
|
|
5273
|
+
id: option.id,
|
|
5274
|
+
type: "custom",
|
|
5275
|
+
renderingMode: "3d",
|
|
5276
|
+
onAdd: function onAdd(map, gl) {
|
|
5277
|
+
this.camera = new THREE.Camera();
|
|
5278
|
+
this.scene = new THREE.Scene();
|
|
5279
|
+
var directionalLight = new THREE.DirectionalLight(0xffffff);
|
|
5280
|
+
directionalLight.position.set(0, -70, 100).normalize();
|
|
5281
|
+
this.scene.add(directionalLight);
|
|
5282
|
+
var directionalLight2 = new THREE.DirectionalLight(0xffffff);
|
|
5283
|
+
directionalLight2.position.set(0, 70, 100).normalize();
|
|
5284
|
+
this.scene.add(directionalLight2);
|
|
5285
|
+
// var loader = new THREE.GLTFLoader();
|
|
5286
|
+
var loader = new THREE.ObjectLoader();
|
|
5287
|
+
var that = this;
|
|
5288
|
+
loader.load(option.url,
|
|
5289
|
+
// 'https://map.sgcc.com.cn/products/js-sdk/v3/assets/model/ZH-SZC3-42.gltf',
|
|
5290
|
+
// function (gltf: any) {
|
|
5291
|
+
function (object) {
|
|
5292
|
+
that.scene.add(object);
|
|
5293
|
+
// that.scene.add(gltf.scene);
|
|
5294
|
+
map.flyTo({
|
|
5295
|
+
center: modelOrigin,
|
|
5296
|
+
// 模型中心坐标
|
|
5297
|
+
zoom: 18,
|
|
5298
|
+
// 缩放级别,可以调整
|
|
5299
|
+
pitch: 75,
|
|
5300
|
+
// 倾斜角度
|
|
5301
|
+
bearing: 0,
|
|
5302
|
+
// 方向角
|
|
5303
|
+
duration: 2000,
|
|
5304
|
+
// 动画持续时间(毫秒)
|
|
5305
|
+
essential: true // 表示此动画对用户体验很重要
|
|
5306
|
+
});
|
|
5307
|
+
}.bind(that));
|
|
5308
|
+
// this.map = map;
|
|
5309
|
+
this.renderer = new THREE.WebGLRenderer({
|
|
5310
|
+
canvas: map.getCanvas(),
|
|
5311
|
+
context: gl
|
|
5312
|
+
});
|
|
5313
|
+
this.renderer.autoClear = false;
|
|
5314
|
+
},
|
|
5315
|
+
render: function render(gl, matrix) {
|
|
5316
|
+
var rotationX = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(1, 0, 0), modelTransform.rotateX);
|
|
5317
|
+
var rotationY = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0, 1, 0), modelTransform.rotateY);
|
|
5318
|
+
var rotationZ = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0, 0, 1), modelTransform.rotateZ);
|
|
5319
|
+
var m = new THREE.Matrix4().fromArray(matrix);
|
|
5320
|
+
var l = new THREE.Matrix4().makeTranslation(modelTransform.translateX, modelTransform.translateY, modelTransform.translateZ).scale(new THREE.Vector3(modelTransform.scale, -modelTransform.scale, modelTransform.scale)).multiply(rotationX).multiply(rotationY).multiply(rotationZ);
|
|
5321
|
+
this.camera.projectionMatrix.elements = matrix;
|
|
5322
|
+
this.camera.projectionMatrix = m.multiply(l);
|
|
5323
|
+
this.renderer.state.reset();
|
|
5324
|
+
this.renderer.render(this.scene, this.camera);
|
|
5325
|
+
}
|
|
5326
|
+
};
|
|
5327
|
+
return config;
|
|
5328
|
+
}
|
|
5329
|
+
}]);
|
|
5330
|
+
}();
|
|
5109
5331
|
var fn = {
|
|
5110
5332
|
mars3d: mars3d_class,
|
|
5111
|
-
gaode: gaode_class
|
|
5333
|
+
gaode: gaode_class,
|
|
5334
|
+
siji: siji_class
|
|
5112
5335
|
};
|
|
5113
5336
|
return fn[hnMap.mapType];
|
|
5114
5337
|
});
|
|
@@ -5363,7 +5586,7 @@
|
|
|
5363
5586
|
* 创建HnMap实例的方法
|
|
5364
5587
|
* @param id 地图容器的ID
|
|
5365
5588
|
* @param option 地图的配置选项
|
|
5366
|
-
* @param mapType
|
|
5589
|
+
* @param mapType 用户期望的地图类型(如 'gaode', 'siji')
|
|
5367
5590
|
*/
|
|
5368
5591
|
return _createClass(HnMap, [{
|
|
5369
5592
|
key: "initModules",
|
|
@@ -5390,86 +5613,136 @@
|
|
|
5390
5613
|
key: "create",
|
|
5391
5614
|
value: function create(id, option, mapType) {
|
|
5392
5615
|
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee() {
|
|
5393
|
-
var basePath,
|
|
5616
|
+
var basePath, innerMap, finalMapType, instance, _t, _t2;
|
|
5394
5617
|
return _regenerator().w(function (_context) {
|
|
5395
5618
|
while (1) switch (_context.p = _context.n) {
|
|
5396
5619
|
case 0:
|
|
5397
|
-
//
|
|
5398
|
-
basePath = window.location.pathname.endsWith("/") ? window.location.pathname : window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1);
|
|
5620
|
+
basePath = window.location.pathname.endsWith("/") ? window.location.pathname : window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/") + 1); // 预加载 turf(所有类型都需要)
|
|
5399
5621
|
_context.n = 1;
|
|
5400
5622
|
return loadResource(basePath + "lib/turf/turf.min.js", "js");
|
|
5401
5623
|
case 1:
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5624
|
+
// 尝试创建地图,支持 fallback
|
|
5625
|
+
innerMap = null;
|
|
5626
|
+
finalMapType = mapType;
|
|
5627
|
+
_context.p = 2;
|
|
5406
5628
|
_context.n = 3;
|
|
5407
|
-
return
|
|
5629
|
+
return HnMap.tryCreateMap(id, option, mapType, basePath);
|
|
5408
5630
|
case 3:
|
|
5409
|
-
|
|
5410
|
-
|
|
5631
|
+
innerMap = _context.v;
|
|
5632
|
+
_context.n = 8;
|
|
5633
|
+
break;
|
|
5411
5634
|
case 4:
|
|
5412
|
-
_context.
|
|
5413
|
-
|
|
5414
|
-
|
|
5635
|
+
_context.p = 4;
|
|
5636
|
+
_t = _context.v;
|
|
5637
|
+
console.warn("[".concat(mapType, "] \u5730\u56FE\u521D\u59CB\u5316\u5931\u8D25\uFF0C\u5C1D\u8BD5\u56DE\u9000\u5230 mars3d"), _t);
|
|
5638
|
+
finalMapType = "mars3d";
|
|
5639
|
+
_context.p = 5;
|
|
5415
5640
|
_context.n = 6;
|
|
5416
|
-
return
|
|
5641
|
+
return HnMap.tryCreateMap(id, option, "mars3d", basePath);
|
|
5417
5642
|
case 6:
|
|
5418
|
-
|
|
5419
|
-
return loadResource(basePath + "lib/mars3d/plugins/heatmap/heatmap.js", "js");
|
|
5420
|
-
case 7:
|
|
5643
|
+
innerMap = _context.v;
|
|
5421
5644
|
_context.n = 8;
|
|
5645
|
+
break;
|
|
5646
|
+
case 7:
|
|
5647
|
+
_context.p = 7;
|
|
5648
|
+
_t2 = _context.v;
|
|
5649
|
+
console.error("mars3d 回退也失败了!", _t2);
|
|
5650
|
+
throw new Error("所有地图类型均无法加载,请检查网络或资源配置");
|
|
5651
|
+
case 8:
|
|
5652
|
+
// 创建 HnMap 实例
|
|
5653
|
+
HnMap.allowConstruction = true;
|
|
5654
|
+
_context.p = 9;
|
|
5655
|
+
instance = new HnMap(id, option, finalMapType, innerMap);
|
|
5656
|
+
instance.initModules();
|
|
5657
|
+
return _context.a(2, instance);
|
|
5658
|
+
case 10:
|
|
5659
|
+
_context.p = 10;
|
|
5660
|
+
HnMap.allowConstruction = false;
|
|
5661
|
+
return _context.f(10);
|
|
5662
|
+
case 11:
|
|
5663
|
+
return _context.a(2);
|
|
5664
|
+
}
|
|
5665
|
+
}, _callee, null, [[9,, 10, 11], [5, 7], [2, 4]]);
|
|
5666
|
+
}));
|
|
5667
|
+
}
|
|
5668
|
+
/**
|
|
5669
|
+
* 尝试根据 mapType 加载资源并创建地图实例
|
|
5670
|
+
*/
|
|
5671
|
+
}, {
|
|
5672
|
+
key: "tryCreateMap",
|
|
5673
|
+
value: function tryCreateMap(id, option, mapType, basePath) {
|
|
5674
|
+
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regenerator().m(function _callee2() {
|
|
5675
|
+
var MapClass, innerMap, _t3;
|
|
5676
|
+
return _regenerator().w(function (_context2) {
|
|
5677
|
+
while (1) switch (_context2.n) {
|
|
5678
|
+
case 0:
|
|
5679
|
+
_t3 = mapType;
|
|
5680
|
+
_context2.n = _t3 === "mars3d" ? 1 : _t3 === "gaode" ? 8 : _t3 === "siji" ? 12 : 17;
|
|
5681
|
+
break;
|
|
5682
|
+
case 1:
|
|
5683
|
+
_context2.n = 2;
|
|
5684
|
+
return loadResource(basePath + "lib/Cesium/Widgets/widgets.css", "css");
|
|
5685
|
+
case 2:
|
|
5686
|
+
_context2.n = 3;
|
|
5687
|
+
return loadResource(basePath + "lib/Cesium/Cesium.js", "js");
|
|
5688
|
+
case 3:
|
|
5689
|
+
_context2.n = 4;
|
|
5690
|
+
return loadResource(basePath + "lib/mars3d/mars3d.css", "css");
|
|
5691
|
+
case 4:
|
|
5692
|
+
_context2.n = 5;
|
|
5693
|
+
return loadResource(basePath + "lib/mars3d/mars3d.js", "js");
|
|
5694
|
+
case 5:
|
|
5695
|
+
_context2.n = 6;
|
|
5696
|
+
return loadResource(basePath + "lib/mars3d/plugins/heatmap/heatmap.js", "js");
|
|
5697
|
+
case 6:
|
|
5698
|
+
_context2.n = 7;
|
|
5422
5699
|
return loadResource(basePath + "lib/mars3d/plugins/heatmap/mars3d-heatmap.js", "js");
|
|
5700
|
+
case 7:
|
|
5701
|
+
return _context2.a(3, 18);
|
|
5423
5702
|
case 8:
|
|
5424
|
-
|
|
5425
|
-
case 9:
|
|
5426
|
-
_context.n = 10;
|
|
5703
|
+
_context2.n = 9;
|
|
5427
5704
|
return loadResource("https://webapi.amap.com/maps?v=2.0&key=".concat(option.gaode_key, "&plugin=AMap.HeatMap,AMap.MarkerCluster,AMap.MoveAnimation"), "js");
|
|
5428
|
-
case
|
|
5429
|
-
|
|
5705
|
+
case 9:
|
|
5706
|
+
_context2.n = 10;
|
|
5430
5707
|
return loadResource("https://a.amap.com/jsapi_demos/static/data3d/lib/three.117.js", "js");
|
|
5431
|
-
case
|
|
5432
|
-
|
|
5708
|
+
case 10:
|
|
5709
|
+
_context2.n = 11;
|
|
5433
5710
|
return loadResource("https://a.amap.com/jsapi_demos/static/data3d/lib/GLTFLoader.117.min.js", "js");
|
|
5711
|
+
case 11:
|
|
5712
|
+
return _context2.a(3, 18);
|
|
5434
5713
|
case 12:
|
|
5435
|
-
|
|
5436
|
-
case 13:
|
|
5437
|
-
_context.n = 14;
|
|
5714
|
+
_context2.n = 13;
|
|
5438
5715
|
return loadResource(option.sj_js_url, "js");
|
|
5716
|
+
case 13:
|
|
5717
|
+
if (!(typeof SGMap === "undefined")) {
|
|
5718
|
+
_context2.n = 14;
|
|
5719
|
+
break;
|
|
5720
|
+
}
|
|
5721
|
+
throw new Error("siji 地图 JS 加载成功但 SGMap 未定义");
|
|
5439
5722
|
case 14:
|
|
5440
|
-
|
|
5723
|
+
_context2.n = 15;
|
|
5441
5724
|
return SGMap.tokenTask.login(option.sj_app_key, option.sj_app_secret);
|
|
5442
5725
|
case 15:
|
|
5443
|
-
|
|
5726
|
+
_context2.n = 16;
|
|
5444
5727
|
return SGMap.plugin(["SGMap.DrawPolygonHandler", "SGMap.DrawCircleHandler", "SGMap.DrawRectangleHandler", "SGMap.GeocodingTask", "SGMap.RoadNetLayer"]);
|
|
5445
5728
|
case 16:
|
|
5446
|
-
return
|
|
5729
|
+
return _context2.a(3, 18);
|
|
5447
5730
|
case 17:
|
|
5731
|
+
throw new Error("\u4E0D\u652F\u6301\u7684\u5730\u56FE\u7C7B\u578B: ".concat(mapType));
|
|
5732
|
+
case 18:
|
|
5448
5733
|
// 2. 创建地图对象
|
|
5449
5734
|
MapClass = map({
|
|
5450
5735
|
id: id,
|
|
5451
5736
|
option: option,
|
|
5452
5737
|
mapType: mapType
|
|
5453
|
-
});
|
|
5454
|
-
|
|
5738
|
+
});
|
|
5739
|
+
_context2.n = 19;
|
|
5455
5740
|
return MapClass.create(id, option);
|
|
5456
|
-
case
|
|
5457
|
-
innerMap =
|
|
5458
|
-
|
|
5459
|
-
// 3. 创建 HnMap 实例(此时传入 map)
|
|
5460
|
-
HnMap.allowConstruction = true;
|
|
5461
|
-
_context.p = 19;
|
|
5462
|
-
instance = new HnMap(id, option, mapType, innerMap); // 4. ✅ 此时 this.map 已存在,再初始化所有模块
|
|
5463
|
-
instance.initModules();
|
|
5464
|
-
return _context.a(2, instance);
|
|
5465
|
-
case 20:
|
|
5466
|
-
_context.p = 20;
|
|
5467
|
-
HnMap.allowConstruction = false;
|
|
5468
|
-
return _context.f(20);
|
|
5469
|
-
case 21:
|
|
5470
|
-
return _context.a(2);
|
|
5741
|
+
case 19:
|
|
5742
|
+
innerMap = _context2.v;
|
|
5743
|
+
return _context2.a(2, innerMap);
|
|
5471
5744
|
}
|
|
5472
|
-
},
|
|
5745
|
+
}, _callee2);
|
|
5473
5746
|
}));
|
|
5474
5747
|
}
|
|
5475
5748
|
}]);
|
package/package.json
CHANGED
package/src/base/siji_entity.ts
CHANGED
|
@@ -202,7 +202,7 @@ export default (hnMap: any) => {
|
|
|
202
202
|
"text-size": Number(option.fontSize),
|
|
203
203
|
"text-anchor": option.verticalOrigin,
|
|
204
204
|
"icon-anchor": option.verticalOrigin,
|
|
205
|
-
|
|
205
|
+
"text-offset": convertPosition(option.offset),
|
|
206
206
|
},
|
|
207
207
|
paint: {
|
|
208
208
|
"text-color": option.color,
|
|
@@ -214,10 +214,7 @@ export default (hnMap: any) => {
|
|
|
214
214
|
set(option: any) {
|
|
215
215
|
deepMerge(this.option, option);
|
|
216
216
|
this.config = this.formatConfig(this.option);
|
|
217
|
-
console.log(this.config, "======CONFIG=====");
|
|
218
|
-
console.log(this.option, "=========OPTION");
|
|
219
217
|
let mySource = hnMap.map.map.getSource(this.config.id);
|
|
220
|
-
console.log(mySource, "=========SOURCE");
|
|
221
218
|
mySource.setData({
|
|
222
219
|
type: "FeatureCollection",
|
|
223
220
|
features: [
|
package/src/graphic/line.ts
CHANGED
package/src/graphic/point.ts
CHANGED
|
@@ -209,7 +209,6 @@ export default (hnMap: any) => {
|
|
|
209
209
|
return [pixelOffset[0] / textSizePx, pixelOffset[1] / textSizePx];
|
|
210
210
|
}
|
|
211
211
|
set(option: any) {
|
|
212
|
-
console.log("=====set point====", option);
|
|
213
212
|
deepMerge(this.option, option);
|
|
214
213
|
this.config = this.formatConfig(this.option);
|
|
215
214
|
let mySource = hnMap.map.map.getSource(this.config.id);
|