gdmap-utils 1.2.3 → 1.2.5
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/.husky/pre-commit +1 -1
- package/.prettierrc.json +17 -17
- package/README.md +467 -2
- package/dist/index.js +127 -7
- package/dist/index.js.map +1 -1
- package/docs/classes/MapUtils.md +153 -0
- package/docs/functions/createMapUtils.md +18 -0
- package/docs/functions/initMapSource.md +14 -0
- package/docs/globals.md +11 -0
- package/examples/1_init.html +23 -23
- package/examples/2_mapInit.html +48 -48
- package/examples/3_MarkerLayer.html +565 -565
- package/examples/4_LabelMarkerLayer.html +574 -574
- package/examples/5_markerCluster.html +528 -0
- package/index.html +134 -134
- package/package.json +54 -51
- package/scripts/cleanDocs.js +220 -0
- package/scripts/mergeDocs.js +129 -0
- package/src/LayerManager.ts +17 -1
- package/src/MapSourceImport.ts +23 -23
- package/src/MapUtils.ts +198 -22
- package/src/gdMap/gdHelper.ts +113 -85
- package/src/index.ts +3 -1
- package/src/layers/baseMarkerLayer/LabelMarkerLayer.ts +240 -240
- package/src/layers/baseMarkerLayer/MarkerLayer.ts +208 -208
- package/src/layers/baseMarkerLayer/index.ts +369 -354
- package/src/layers/clusterMarkerLayer/MarkerClusterLayer.ts +53 -53
- package/src/layers/clusterMarkerLayer/index.ts +204 -177
- package/src/layers/index.ts +9 -9
- package/src/types/MapUtils.d.ts +53 -53
- package/src/types/amap.d.ts +11 -11
- package/src/types/{BaseMarkerLayer.d.ts → baseMarkerLayer.d.ts} +86 -87
- package/src/types/clusterMarkerLayer.d.ts +89 -88
- package/src/types/index.d.ts +14 -14
- package/tsconfig.json +26 -26
- package/typedoc.json +22 -0
- package/webpack.config.js +125 -126
- package/src/gdMap/gdHelper.js +0 -194
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
mapIns,
|
|
3
|
-
MarkerClusterDataOptions,
|
|
4
|
-
MarkerClusterOptions,
|
|
5
|
-
} from '@/types/index.d';
|
|
6
|
-
|
|
7
|
-
class MarkerClusterLayer {
|
|
8
|
-
rawLayer: any; //高德未提供cluster的类型
|
|
9
|
-
|
|
10
|
-
map: mapIns;
|
|
11
|
-
|
|
12
|
-
constructor(
|
|
13
|
-
map: mapIns,
|
|
14
|
-
dataOptions: Array<MarkerClusterDataOptions>,
|
|
15
|
-
opts: MarkerClusterOptions
|
|
16
|
-
) {
|
|
17
|
-
this.map = map;
|
|
18
|
-
//@ts-expect-error
|
|
19
|
-
this.rawLayer = new AMap.MarkerCluster(map, dataOptions, opts);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
bindEventMarker(clickType: AMap.EventType, callback: () => void) {
|
|
23
|
-
this.rawLayer.on(clickType, callback);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
add(dataOption: MarkerClusterDataOptions) {
|
|
27
|
-
this.rawLayer.addData(dataOption);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
remove(dataOptions: Array<MarkerClusterDataOptions>) {
|
|
31
|
-
this.rawLayer.setData(dataOptions);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
hide() {
|
|
35
|
-
this.rawLayer.setData([]);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
show(dataOptions: Array<MarkerClusterDataOptions>) {
|
|
39
|
-
this.rawLayer.setData(dataOptions);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
destroy() {
|
|
43
|
-
this.rawLayer.setData([]);
|
|
44
|
-
this.rawLayer.setMap(null);
|
|
45
|
-
this.rawLayer = null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
clearAllOvl() {
|
|
49
|
-
this.rawLayer.setData([]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default MarkerClusterLayer;
|
|
1
|
+
import type {
|
|
2
|
+
mapIns,
|
|
3
|
+
MarkerClusterDataOptions,
|
|
4
|
+
MarkerClusterOptions,
|
|
5
|
+
} from '@/types/index.d';
|
|
6
|
+
|
|
7
|
+
class MarkerClusterLayer {
|
|
8
|
+
rawLayer: any; //高德未提供cluster的类型
|
|
9
|
+
|
|
10
|
+
map: mapIns;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
map: mapIns,
|
|
14
|
+
dataOptions: Array<MarkerClusterDataOptions>,
|
|
15
|
+
opts: MarkerClusterOptions
|
|
16
|
+
) {
|
|
17
|
+
this.map = map;
|
|
18
|
+
//@ts-expect-error
|
|
19
|
+
this.rawLayer = new AMap.MarkerCluster(map, dataOptions, opts);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
bindEventMarker(clickType: AMap.EventType, callback: () => void) {
|
|
23
|
+
this.rawLayer.on(clickType, callback);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
add(dataOption: MarkerClusterDataOptions[]) {
|
|
27
|
+
this.rawLayer.addData(dataOption);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
remove(dataOptions: Array<MarkerClusterDataOptions>) {
|
|
31
|
+
this.rawLayer.setData(dataOptions);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
hide() {
|
|
35
|
+
this.rawLayer.setData([]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
show(dataOptions: Array<MarkerClusterDataOptions>) {
|
|
39
|
+
this.rawLayer.setData(dataOptions);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
destroy() {
|
|
43
|
+
this.rawLayer.setData([]);
|
|
44
|
+
this.rawLayer.setMap(null);
|
|
45
|
+
this.rawLayer = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
clearAllOvl() {
|
|
49
|
+
this.rawLayer.setData([]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default MarkerClusterLayer;
|
|
@@ -1,177 +1,204 @@
|
|
|
1
|
-
import MarkerClusterLayer from './MarkerClusterLayer';
|
|
2
|
-
import type {
|
|
3
|
-
MarkerClusterLayerType,
|
|
4
|
-
OverlayData, //OverLayerData图层公共接口
|
|
5
|
-
MarkerClusterDataOptions,
|
|
6
|
-
ClusterMarkerLayerInfo,
|
|
7
|
-
ClusterMarkerLayerOpts,
|
|
8
|
-
} from '@/types';
|
|
9
|
-
import { MapUtils } from '@/MapUtils';
|
|
10
|
-
import type { mapUtilsIns } from '@/MapUtils';
|
|
11
|
-
|
|
12
|
-
class ClusterMarkerLayer<
|
|
13
|
-
U extends object,
|
|
14
|
-
T extends MarkerClusterLayerType = 'markerClusterLayer',
|
|
15
|
-
V extends ClusterMarkerLayerInfo[T] = ClusterMarkerLayerInfo[T],
|
|
16
|
-
> {
|
|
17
|
-
// 图层类型与控制器类的映射关系
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
this.overlayList
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.overlayList
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
1
|
+
import MarkerClusterLayer from './MarkerClusterLayer';
|
|
2
|
+
import type {
|
|
3
|
+
MarkerClusterLayerType,
|
|
4
|
+
OverlayData, //OverLayerData图层公共接口
|
|
5
|
+
MarkerClusterDataOptions,
|
|
6
|
+
ClusterMarkerLayerInfo,
|
|
7
|
+
ClusterMarkerLayerOpts,
|
|
8
|
+
} from '@/types';
|
|
9
|
+
import { MapUtils } from '@/MapUtils';
|
|
10
|
+
import type { mapUtilsIns } from '@/MapUtils';
|
|
11
|
+
|
|
12
|
+
class ClusterMarkerLayer<
|
|
13
|
+
U extends object,
|
|
14
|
+
T extends MarkerClusterLayerType = 'markerClusterLayer',
|
|
15
|
+
V extends ClusterMarkerLayerInfo[T] = ClusterMarkerLayerInfo[T],
|
|
16
|
+
> {
|
|
17
|
+
// 图层类型与控制器类的映射关系
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*@ignore
|
|
21
|
+
*/
|
|
22
|
+
static layerClassMap = new Map<string, ClusterMarkerLayerTypeClass>();
|
|
23
|
+
/**
|
|
24
|
+
* 注册图层类型与控制器类的关联
|
|
25
|
+
* @param {string} layerType - 图层类型
|
|
26
|
+
* @param {Function} layerClass - 图层控制器类
|
|
27
|
+
* @ignore
|
|
28
|
+
*/
|
|
29
|
+
static registerLayer(
|
|
30
|
+
layerType: MarkerClusterLayerType,
|
|
31
|
+
layerClass: ClusterMarkerLayerTypeClass
|
|
32
|
+
) {
|
|
33
|
+
if (typeof layerType !== 'string' || typeof layerClass !== 'function') {
|
|
34
|
+
MapUtils.error(
|
|
35
|
+
'[ClusterMarkerLayer Error]: Invalid layer type or layer class'
|
|
36
|
+
);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ClusterMarkerLayer.layerClassMap.set(layerType, layerClass);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
overlayList: Array<OverlayData<U>>;
|
|
44
|
+
// 策略模式
|
|
45
|
+
rawLayerIns: V['layerIns'];
|
|
46
|
+
|
|
47
|
+
layerVisible: boolean = true;
|
|
48
|
+
|
|
49
|
+
layerName: string;
|
|
50
|
+
|
|
51
|
+
mapUtils: mapUtilsIns;
|
|
52
|
+
|
|
53
|
+
layerType: MarkerClusterLayerType;
|
|
54
|
+
|
|
55
|
+
constructor(opts: ClusterMarkerLayerOpts<U, T>, mapUtils: mapUtilsIns) {
|
|
56
|
+
const { layerType, layerName, ...rest } = opts;
|
|
57
|
+
|
|
58
|
+
const OverlaysLayer = ClusterMarkerLayer.layerClassMap.get(layerType);
|
|
59
|
+
|
|
60
|
+
if (OverlaysLayer) {
|
|
61
|
+
// 将OverlayData转换为MarkerClusterDataOptions
|
|
62
|
+
const clusterData = this.convertOverlayDataToClusterData(
|
|
63
|
+
opts.overlayList
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
this.rawLayerIns = new OverlaysLayer(
|
|
67
|
+
mapUtils.map,
|
|
68
|
+
clusterData,
|
|
69
|
+
opts.layerOpts
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`[ClusterMarkerLayer Error]: Invalid layer type ${layerType}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.layerName = layerName;
|
|
78
|
+
|
|
79
|
+
this.mapUtils = mapUtils; //mapUtils的实例
|
|
80
|
+
|
|
81
|
+
this.overlayList = opts.overlayList;
|
|
82
|
+
|
|
83
|
+
this.layerType = opts.layerType;
|
|
84
|
+
|
|
85
|
+
Object.assign(this, rest);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 将覆盖物数据转换为聚合标记所需的数据格式
|
|
90
|
+
* @param overlayList 覆盖物数据列表
|
|
91
|
+
* @returns 聚合标记数据列表
|
|
92
|
+
*/
|
|
93
|
+
private convertOverlayDataToClusterData(
|
|
94
|
+
overlayList: Array<OverlayData<U>>
|
|
95
|
+
): Array<MarkerClusterDataOptions> {
|
|
96
|
+
return overlayList.map(item => {
|
|
97
|
+
return {
|
|
98
|
+
...item,
|
|
99
|
+
lnglat: [item.overlayData.lon, item.overlayData.lat],
|
|
100
|
+
weight: item.overlayData.weight || 1,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
bindEventOverlays(clickType: AMap.EventType, callback: () => void) {
|
|
106
|
+
this.rawLayerIns.bindEventMarker(clickType, callback);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
hide() {
|
|
110
|
+
this.layerVisible = false;
|
|
111
|
+
this.rawLayerIns.hide();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
show() {
|
|
115
|
+
this.layerVisible = true;
|
|
116
|
+
const clusterData = this.convertOverlayDataToClusterData(this.overlayList);
|
|
117
|
+
this.rawLayerIns.show(clusterData);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
destroy() {
|
|
121
|
+
this.mapUtils.removeLayer(this); //从MapUtils中移除
|
|
122
|
+
this.rawLayerIns.destroy(); //地图层面移除
|
|
123
|
+
this.overlayList = [];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
clearAllOverlay() {
|
|
127
|
+
this.overlayList = [];
|
|
128
|
+
this.rawLayerIns.clearAllOvl();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
add(overlayList: Array<OverlayData<U>>) {
|
|
132
|
+
const clusterData = this.convertOverlayDataToClusterData(overlayList);
|
|
133
|
+
|
|
134
|
+
this.overlayList.push(...overlayList);
|
|
135
|
+
|
|
136
|
+
// 逐个添加聚合数据
|
|
137
|
+
this.rawLayerIns.add(clusterData);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* `remove`
|
|
142
|
+
*
|
|
143
|
+
* @param {(Array<number | string>)} ovs
|
|
144
|
+
* @memberof ClusterMarkerLayer
|
|
145
|
+
*/
|
|
146
|
+
remove(ovs: Array<number | string>) {
|
|
147
|
+
if (Array.isArray(ovs)) {
|
|
148
|
+
// 根据ID移除覆盖物
|
|
149
|
+
const ids = ovs as Array<string | number>;
|
|
150
|
+
|
|
151
|
+
// 更新本地覆盖物列表
|
|
152
|
+
this.overlayList = this.overlayList.filter(
|
|
153
|
+
item => !ids.includes(item.id)
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
// 重新设置聚合数据
|
|
157
|
+
const clusterData = this.convertOverlayDataToClusterData(
|
|
158
|
+
this.overlayList
|
|
159
|
+
);
|
|
160
|
+
this.rawLayerIns.remove(clusterData);
|
|
161
|
+
}
|
|
162
|
+
// 聚合图层不支持直接移除单个实例
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
*
|
|
167
|
+
*`getRawLayer`方法返回高德覆盖物管理对象, 例如: 图层类型为`markerClusterLayer`,方法返回的对象类型为`new AMap.MarkerCluster(xx,'xxx')`
|
|
168
|
+
* @return {*}
|
|
169
|
+
*/
|
|
170
|
+
getRawLayer() {
|
|
171
|
+
return this.rawLayerIns.rawLayer;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 注册聚合图层类型
|
|
176
|
+
ClusterMarkerLayer.registerLayer('markerClusterLayer', MarkerClusterLayer);
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* MarkerClusterLayer 类型
|
|
180
|
+
* @ignore
|
|
181
|
+
*/
|
|
182
|
+
export type MarkerClusterLayerIns = InstanceType<typeof MarkerClusterLayer>;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 所有聚合图层类型的联合类型
|
|
186
|
+
* @ignore
|
|
187
|
+
*/
|
|
188
|
+
export type ClusterMarkerLayerTypeIns = MarkerClusterLayerIns;
|
|
189
|
+
/**
|
|
190
|
+
* @ignore
|
|
191
|
+
*/
|
|
192
|
+
export type ClusterMarkerLayerTypeClass = typeof MarkerClusterLayer;
|
|
193
|
+
/**
|
|
194
|
+
* @ignore
|
|
195
|
+
*/
|
|
196
|
+
export type ClusterMarkerLayerClass = typeof ClusterMarkerLayer;
|
|
197
|
+
/**
|
|
198
|
+
* @ignore
|
|
199
|
+
*/
|
|
200
|
+
export type ClusterMarkerLayerIns = InstanceType<ClusterMarkerLayerClass>;
|
|
201
|
+
|
|
202
|
+
export { MarkerClusterLayer };
|
|
203
|
+
|
|
204
|
+
export default ClusterMarkerLayer;
|
package/src/layers/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// 图层模块入口文件
|
|
2
|
-
// 从baseMarkerLayer目录导入BaseMarkerLayer相关内容并重新导出
|
|
3
|
-
export type * from './baseMarkerLayer';
|
|
4
|
-
|
|
5
|
-
export type * from './clusterMarkerLayer';
|
|
6
|
-
|
|
7
|
-
export { default as BaseMarkerLayer } from './baseMarkerLayer';
|
|
8
|
-
|
|
9
|
-
export { default as ClusterMarkerLayer } from './clusterMarkerLayer';
|
|
1
|
+
// 图层模块入口文件
|
|
2
|
+
// 从baseMarkerLayer目录导入BaseMarkerLayer相关内容并重新导出
|
|
3
|
+
export type * from './baseMarkerLayer';
|
|
4
|
+
|
|
5
|
+
export type * from './clusterMarkerLayer';
|
|
6
|
+
|
|
7
|
+
export { default as BaseMarkerLayer } from './baseMarkerLayer';
|
|
8
|
+
|
|
9
|
+
export { default as ClusterMarkerLayer } from './clusterMarkerLayer';
|
package/src/types/MapUtils.d.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
// 高德地图实例
|
|
2
|
-
type mapIns = InstanceType<typeof AMap.Map>;
|
|
3
|
-
|
|
4
|
-
type MapOptions = AMap.MapOptions;
|
|
5
|
-
|
|
6
|
-
interface MapUtilsCreateOpts extends MapOptions {
|
|
7
|
-
mountSelector: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
interface MapUtilsUseExistingOpts extends MapOptions {
|
|
11
|
-
mapIns: mapIns;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type MapUtilsOpts = {
|
|
15
|
-
MapUtilsUseExistingOpts: MapUtilsUseExistingOpts;
|
|
16
|
-
MapUtilsCreateOpts: MapUtilsCreateOpts;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
interface MapUtilsStatic extends MapMixinType {
|
|
20
|
-
new (
|
|
21
|
-
opts: MapUtilsOpts[keyof MapUtilsOpts],
|
|
22
|
-
AMap: Simplify<typeof gdAMap>
|
|
23
|
-
): MapUtils;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 图层管理器
|
|
27
|
-
interface LayerManger<T = new (...args: any[]) => any, K = InstanceType<T>> {
|
|
28
|
-
layers: Map<string, K>; //组合模式
|
|
29
|
-
|
|
30
|
-
addLayer(layer: K): void;
|
|
31
|
-
|
|
32
|
-
removeLayer(layerIdOrLayer: K | string): void;
|
|
33
|
-
|
|
34
|
-
show(): void;
|
|
35
|
-
|
|
36
|
-
hide(): void;
|
|
37
|
-
|
|
38
|
-
showAll(): void;
|
|
39
|
-
|
|
40
|
-
hideAll(): void;
|
|
41
|
-
|
|
42
|
-
reload(): void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type {
|
|
46
|
-
mapIns,
|
|
47
|
-
MapOptions,
|
|
48
|
-
MapUtilsCreateOpts,
|
|
49
|
-
MapUtilsUseExistingOpts,
|
|
50
|
-
MapUtilsOpts,
|
|
51
|
-
LayerManger,
|
|
52
|
-
MapUtilsStatic,
|
|
53
|
-
};
|
|
1
|
+
// 高德地图实例
|
|
2
|
+
type mapIns = InstanceType<typeof AMap.Map>;
|
|
3
|
+
|
|
4
|
+
type MapOptions = AMap.MapOptions;
|
|
5
|
+
|
|
6
|
+
interface MapUtilsCreateOpts extends MapOptions {
|
|
7
|
+
mountSelector: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface MapUtilsUseExistingOpts extends MapOptions {
|
|
11
|
+
mapIns: mapIns;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type MapUtilsOpts = {
|
|
15
|
+
MapUtilsUseExistingOpts: MapUtilsUseExistingOpts;
|
|
16
|
+
MapUtilsCreateOpts: MapUtilsCreateOpts;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
interface MapUtilsStatic extends MapMixinType {
|
|
20
|
+
new (
|
|
21
|
+
opts: MapUtilsOpts[keyof MapUtilsOpts],
|
|
22
|
+
AMap: Simplify<typeof gdAMap>
|
|
23
|
+
): MapUtils;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 图层管理器
|
|
27
|
+
interface LayerManger<T = new (...args: any[]) => any, K = InstanceType<T>> {
|
|
28
|
+
layers: Map<string, K>; //组合模式
|
|
29
|
+
|
|
30
|
+
addLayer(layer: K): void;
|
|
31
|
+
|
|
32
|
+
removeLayer(layerIdOrLayer: K | string): void;
|
|
33
|
+
|
|
34
|
+
show(): void;
|
|
35
|
+
|
|
36
|
+
hide(): void;
|
|
37
|
+
|
|
38
|
+
showAll(): void;
|
|
39
|
+
|
|
40
|
+
hideAll(): void;
|
|
41
|
+
|
|
42
|
+
reload(): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type {
|
|
46
|
+
mapIns,
|
|
47
|
+
MapOptions,
|
|
48
|
+
MapUtilsCreateOpts,
|
|
49
|
+
MapUtilsUseExistingOpts,
|
|
50
|
+
MapUtilsOpts,
|
|
51
|
+
LayerManger,
|
|
52
|
+
MapUtilsStatic,
|
|
53
|
+
};
|
package/src/types/amap.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// 导入高德地图类型声明
|
|
2
|
-
import type { load } from '@amap/amap-jsapi-loader';
|
|
3
|
-
import '@amap/amap-jsapi-types';
|
|
4
|
-
|
|
5
|
-
type loaderOpts = Parameters<typeof load>[0]; //函数类型取出
|
|
6
|
-
|
|
7
|
-
type MapOptions = AMap.MapOptions;
|
|
8
|
-
type MarkerOptions = AMap.MarkerOptions;
|
|
9
|
-
type LabelMarkerOptions = AMap.LabelMarkerOptions;
|
|
10
|
-
|
|
11
|
-
export type { loaderOpts, AMap, MapOptions, MarkerOptions, LabelMarkerOptions };
|
|
1
|
+
// 导入高德地图类型声明
|
|
2
|
+
import type { load } from '@amap/amap-jsapi-loader';
|
|
3
|
+
import '@amap/amap-jsapi-types';
|
|
4
|
+
|
|
5
|
+
type loaderOpts = Parameters<typeof load>[0]; //函数类型取出
|
|
6
|
+
|
|
7
|
+
type MapOptions = AMap.MapOptions;
|
|
8
|
+
type MarkerOptions = AMap.MarkerOptions;
|
|
9
|
+
type LabelMarkerOptions = AMap.LabelMarkerOptions;
|
|
10
|
+
|
|
11
|
+
export type { loaderOpts, AMap, MapOptions, MarkerOptions, LabelMarkerOptions };
|