hn-map 1.1.2 → 1.1.3

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.
@@ -0,0 +1,120 @@
1
+ import { deepMerge, wgs84ToGcj02Format } from "../util";
2
+
3
+ export default (hnMap: any) => {
4
+ const defaultOption = {
5
+ id: "",
6
+ position: [],
7
+ addressName: "", //地址名称
8
+ region: "", //地址
9
+ isEncode: false, //是否进行坐标转换
10
+ iconSize: 13,
11
+ offfset: [0, 0],
12
+ color: "#fff",
13
+ text: "",
14
+ data: null,
15
+ };
16
+
17
+ class mars3d_class {
18
+ type: any = "geocodingTask";
19
+ id: any = null;
20
+ option: any = JSON.parse(JSON.stringify(defaultOption));
21
+ config: any = null;
22
+ layerEntity: any = null;
23
+
24
+ constructor(option: any) {
25
+ this.id = option.id;
26
+ deepMerge(this.option, option);
27
+ this.config = this.formatConfig(this.option);
28
+ this.layerEntity = new mars3d.layer.HeatLayer(
29
+ JSON.parse(JSON.stringify(this.config))
30
+ );
31
+ }
32
+
33
+ formatConfig(option: any) {
34
+ return {
35
+ id: option.id,
36
+ positions: option.position,
37
+
38
+ style: {
39
+ opacity: option.opacity,
40
+ scaleByDistance: option.scaleByDistance,
41
+ clampToGround: option.clampToGround,
42
+ },
43
+
44
+ attr: option.data,
45
+ };
46
+ }
47
+
48
+ set(option: any) {
49
+ deepMerge(this.option, option);
50
+ this.config = this.formatConfig(this.option);
51
+ this.layerEntity.setOptions(this.config);
52
+ }
53
+
54
+ destroy() {
55
+ this.layerEntity.remove(true);
56
+ hnMap.map.layerList = hnMap.map.layerList.filter(
57
+ (v: any) => v.id !== this.id
58
+ );
59
+ }
60
+
61
+ flyTo() {
62
+ this.layerEntity.flyTo();
63
+ }
64
+
65
+ clear() {
66
+ this.layerEntity.clear();
67
+ }
68
+
69
+ setPosition(position: any) {
70
+ deepMerge(this.option, { position });
71
+ this.layerEntity.setPositions(position);
72
+ }
73
+
74
+ show() {
75
+ this.layerEntity.show = true;
76
+ }
77
+
78
+ hide() {
79
+ this.layerEntity.show = false;
80
+ }
81
+ }
82
+
83
+ class siji_class {
84
+ id: any = null;
85
+ option: any = JSON.parse(JSON.stringify(defaultOption));
86
+ config: any = null;
87
+ layerEntity: any = null;
88
+
89
+ constructor(option: any) {
90
+ this.id = option.id;
91
+ deepMerge(this.option, option);
92
+ this.layerEntity = new SGMap.GeocodingTask();
93
+ }
94
+
95
+ getLnglat(option: any) {
96
+ // return new Promise((resolve, reject) => {
97
+ this.layerEntity
98
+ .getLocation({
99
+ address: option.addressName,
100
+ region: option.region,
101
+ isEncode: option.isEncode,
102
+ })
103
+ .then(function (res: any) {
104
+ return res.location;
105
+ });
106
+ // });
107
+ }
108
+
109
+ easeTo(option: any) {
110
+ hnMap.map.map.easeTo(option);
111
+ }
112
+ }
113
+
114
+ const fn: any = {
115
+ mars3d: mars3d_class,
116
+ siji: siji_class,
117
+ };
118
+
119
+ return fn[hnMap.mapType];
120
+ };