gdmap-utils 1.2.0 → 1.2.2
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 +2 -50
- package/dist/index.js +1 -83
- package/dist/index.js.map +1 -1
- 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/index.html +134 -134
- package/package.json +48 -48
- package/src/LayerManager.ts +49 -49
- package/src/MapSourceImport.ts +23 -23
- package/src/MapUtils.ts +154 -154
- package/src/gdMap/gdHelper.js +194 -194
- package/src/gdMap/gdHelper.ts +85 -85
- package/src/gdMapUtils.js +377 -377
- package/src/index.ts +1 -1
- package/src/layers/baseMarkerLayer/LabelMarkerLayer.ts +238 -238
- package/src/layers/baseMarkerLayer/MarkerLayer.ts +206 -206
- package/src/layers/baseMarkerLayer/index.ts +354 -354
- package/src/{layers copy/MarkerClusterLayer.js → layers/clusterMarkerLayer/MarkerClusterLayer.js} +155 -155
- package/src/layers/{MarkerClusterLayer.ts → clusterMarkerLayer/MarkerClusterLayer.ts} +30 -30
- package/src/layers/index.ts +5 -5
- package/src/types/BaseMarkerLayer.d.ts +87 -87
- package/src/types/MapUtils.d.ts +53 -53
- package/src/types/amap.d.ts +11 -11
- package/src/types/index.d.ts +12 -12
- package/tsconfig.json +26 -26
- package/webpack.config.js +126 -126
- package/src/layers copy/LabelMarkerLayer.js +0 -122
- package/src/layers copy/MarkerLayer.js +0 -267
- package/src/layers copy/OverlayGroupManager.js +0 -254
- package/src/layers copy/index.ts +0 -0
package/src/gdMap/gdHelper.js
CHANGED
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
const gdHelperMixin = {
|
|
2
|
-
/**
|
|
3
|
-
* 设置地图中心
|
|
4
|
-
* @param lnglat [xxx,xx]
|
|
5
|
-
* @param zoom 地图层级
|
|
6
|
-
*/
|
|
7
|
-
//TODO setGDMapCenter 你可以为后期迭代做准备
|
|
8
|
-
//TODO setGDMapCenter 你可以为后期迭代做准备
|
|
9
|
-
setCenter(lnglat, zoom) {
|
|
10
|
-
if (zoom !== undefined) {
|
|
11
|
-
this.map.setZoomAndCenter(zoom, lnglat); //同时设置地图层级与中心点
|
|
12
|
-
} else {
|
|
13
|
-
this.map.setCenter(lnglat, true);
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
/**
|
|
17
|
-
* 设置地图缩放级别
|
|
18
|
-
* @param zoom 地图层级
|
|
19
|
-
*/
|
|
20
|
-
setZoom(zoom) {
|
|
21
|
-
this.map.setZoom(zoom);
|
|
22
|
-
},
|
|
23
|
-
/**
|
|
24
|
-
* 根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别
|
|
25
|
-
* @param {Array} overlays [marker, marker1] 覆盖物数组 缺省为全部覆盖物
|
|
26
|
-
* @param {Boolean} immediately 是否立即过渡
|
|
27
|
-
* @param {Array<Number>} avoid [60,60,60,60] 四周边距,上、下、左、右
|
|
28
|
-
* @param {number} maxZoom 最大 地图zoom 级别 18
|
|
29
|
-
*/
|
|
30
|
-
setFitView(...opts) {
|
|
31
|
-
// 地图适应到最佳视角
|
|
32
|
-
this.map.setFitView(...opts);
|
|
33
|
-
},
|
|
34
|
-
/**
|
|
35
|
-
* 创建一个图标
|
|
36
|
-
* @param {[number, number]} size - 图标尺寸,格式为 [width, height]
|
|
37
|
-
* @param {string} image - 图片的 URL 地址
|
|
38
|
-
* @param {[number, number]} imageSize - 图标所用图片的大小,格式为 [width, height]
|
|
39
|
-
* @param {[number, number]} imageOffset - 图标取图的偏移量,格式为 [x, y]
|
|
40
|
-
*/
|
|
41
|
-
createIcon(size, image, imageSize, imageOffset = [0, 0]) {
|
|
42
|
-
return new this.AMap.Icon({
|
|
43
|
-
// 图标尺寸
|
|
44
|
-
size: this.Size(...size),
|
|
45
|
-
// 图标的取图地址
|
|
46
|
-
image: image,
|
|
47
|
-
// 图标所用图片大小
|
|
48
|
-
imageSize: this.Size(...imageSize),
|
|
49
|
-
// 图标取图偏移量
|
|
50
|
-
imageOffset: this.Pixel(...imageOffset),
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* 地物对象的像素尺寸
|
|
55
|
-
* @param {number} width 宽度
|
|
56
|
-
* @param {number} height 高度
|
|
57
|
-
*/
|
|
58
|
-
Size(width, height) {
|
|
59
|
-
return new this.AMap.Size(width, height);
|
|
60
|
-
},
|
|
61
|
-
/**
|
|
62
|
-
* 像素坐标,确定地图上的一个像素点。
|
|
63
|
-
* @param {number} x
|
|
64
|
-
* @param {number} y
|
|
65
|
-
*/
|
|
66
|
-
Pixel(x, y) {
|
|
67
|
-
return new this.AMap.Pixel(x, y);
|
|
68
|
-
},
|
|
69
|
-
/**
|
|
70
|
-
* 经纬度坐标,用来描述地图上的一个点位置
|
|
71
|
-
* @param {Number} lng 经度值
|
|
72
|
-
* @param {Number} lat 纬度值
|
|
73
|
-
* @param {boolean} noWrap 是否自动将经度值修正到 [-180,180] 区间内
|
|
74
|
-
*/
|
|
75
|
-
LngLat(lng, lat, noWrap = false) {
|
|
76
|
-
return new this.AMap.LngLat(lng, lat, noWrap);
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
//TODO 海量点数据
|
|
80
|
-
createLabelLayer({
|
|
81
|
-
zoom = [1, 20],
|
|
82
|
-
zIndex = 1000,
|
|
83
|
-
collision = true,
|
|
84
|
-
layerClassName,
|
|
85
|
-
...rest
|
|
86
|
-
}) {
|
|
87
|
-
const labelLayer = new this.AMap.LabelsLayer({
|
|
88
|
-
zIndex,
|
|
89
|
-
collision,
|
|
90
|
-
zoom,
|
|
91
|
-
...rest,
|
|
92
|
-
});
|
|
93
|
-
labelLayer.setMap(this.map);
|
|
94
|
-
// HACK: labelLayer获取图层节点方式与原来不同,获取可以抽象marker图层, labelLayer图层,实现多态
|
|
95
|
-
// this.overlayGroupManagerMap.set(layerClassName,labelLayer);
|
|
96
|
-
return labelLayer;
|
|
97
|
-
},
|
|
98
|
-
// 创建labelMarker标注
|
|
99
|
-
createLabelLayerMarker({ icon, text, position, ...rest }) {
|
|
100
|
-
const label = new this.AMap.LabelMarker({
|
|
101
|
-
icon: icon,
|
|
102
|
-
text: text,
|
|
103
|
-
position: position,
|
|
104
|
-
...rest,
|
|
105
|
-
});
|
|
106
|
-
return label;
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
createMarkerCluster(
|
|
110
|
-
points,
|
|
111
|
-
{ _renderClusterMarker, _renderMarker, gridSize }
|
|
112
|
-
) {
|
|
113
|
-
return new AMap.MarkerCluster(this.map, points, {
|
|
114
|
-
gridSize: gridSize, // 设置网格像素大小
|
|
115
|
-
renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式
|
|
116
|
-
renderMarker: _renderMarker, // 自定义非聚合点样式
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
/*
|
|
120
|
-
创建点位信息窗体
|
|
121
|
-
*/
|
|
122
|
-
createInfoWindow({
|
|
123
|
-
content,
|
|
124
|
-
isCustom = true,
|
|
125
|
-
closeWhenClickMap = true,
|
|
126
|
-
...rest
|
|
127
|
-
}) {
|
|
128
|
-
return new this.AMap.InfoWindow({
|
|
129
|
-
content: content,
|
|
130
|
-
isCustom,
|
|
131
|
-
closeWhenClickMap: closeWhenClickMap,
|
|
132
|
-
...rest,
|
|
133
|
-
});
|
|
134
|
-
},
|
|
135
|
-
/*
|
|
136
|
-
清楚地图所有信息窗体
|
|
137
|
-
*/
|
|
138
|
-
clearInfoWindow() {
|
|
139
|
-
this.map.clearInfoWindow();
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
//[ ] gdHelper.js中this.map.xxx得方法可以转移到gdUtils.js实例上,mapUtils
|
|
143
|
-
/* 打开高德信息弹框 */
|
|
144
|
-
openInfoWindow(infoWindow, ...rest) {
|
|
145
|
-
infoWindow.open(this.map, ...rest);
|
|
146
|
-
},
|
|
147
|
-
// 绘制线路
|
|
148
|
-
drawPolyline(paths) {
|
|
149
|
-
return new this.AMap.Polyline({
|
|
150
|
-
map: this.map,
|
|
151
|
-
...paths,
|
|
152
|
-
});
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
clearOverlays() {
|
|
156
|
-
this.map.clearMap(); // 清除地图上的所有覆盖物
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
removeSingleOverlay(overlay) {
|
|
160
|
-
this.map.remove(overlay); // 清除地图上某个覆盖物
|
|
161
|
-
},
|
|
162
|
-
/**
|
|
163
|
-
* 创建高德地图驾车导航
|
|
164
|
-
* @param {Object} options 导航配置
|
|
165
|
-
* @returns {AMap.Driving} 导航对象
|
|
166
|
-
*/
|
|
167
|
-
createAMapDriving(options) {
|
|
168
|
-
return new this.AMap.Driving(options);
|
|
169
|
-
},
|
|
170
|
-
/**
|
|
171
|
-
* 创建高德地图标注
|
|
172
|
-
* @param {Object} options 标注配置
|
|
173
|
-
* @returns {AMap.Marker} 标注对象
|
|
174
|
-
*/
|
|
175
|
-
createAMapMarker(options) {
|
|
176
|
-
return new this.AMap.Marker({
|
|
177
|
-
map: this.map,
|
|
178
|
-
...options,
|
|
179
|
-
});
|
|
180
|
-
},
|
|
181
|
-
/**
|
|
182
|
-
* 创建高德地图折线
|
|
183
|
-
* @param {Object} options 折线配置
|
|
184
|
-
* @returns {AMap.Polyline} 折线对象
|
|
185
|
-
*/
|
|
186
|
-
createAMapPolyline(options) {
|
|
187
|
-
return new this.AMap.Polyline({
|
|
188
|
-
map: this.map,
|
|
189
|
-
...options,
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export default gdHelperMixin;
|
|
1
|
+
const gdHelperMixin = {
|
|
2
|
+
/**
|
|
3
|
+
* 设置地图中心
|
|
4
|
+
* @param lnglat [xxx,xx]
|
|
5
|
+
* @param zoom 地图层级
|
|
6
|
+
*/
|
|
7
|
+
//TODO setGDMapCenter 你可以为后期迭代做准备
|
|
8
|
+
//TODO setGDMapCenter 你可以为后期迭代做准备
|
|
9
|
+
setCenter(lnglat, zoom) {
|
|
10
|
+
if (zoom !== undefined) {
|
|
11
|
+
this.map.setZoomAndCenter(zoom, lnglat); //同时设置地图层级与中心点
|
|
12
|
+
} else {
|
|
13
|
+
this.map.setCenter(lnglat, true);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* 设置地图缩放级别
|
|
18
|
+
* @param zoom 地图层级
|
|
19
|
+
*/
|
|
20
|
+
setZoom(zoom) {
|
|
21
|
+
this.map.setZoom(zoom);
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* 根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别
|
|
25
|
+
* @param {Array} overlays [marker, marker1] 覆盖物数组 缺省为全部覆盖物
|
|
26
|
+
* @param {Boolean} immediately 是否立即过渡
|
|
27
|
+
* @param {Array<Number>} avoid [60,60,60,60] 四周边距,上、下、左、右
|
|
28
|
+
* @param {number} maxZoom 最大 地图zoom 级别 18
|
|
29
|
+
*/
|
|
30
|
+
setFitView(...opts) {
|
|
31
|
+
// 地图适应到最佳视角
|
|
32
|
+
this.map.setFitView(...opts);
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* 创建一个图标
|
|
36
|
+
* @param {[number, number]} size - 图标尺寸,格式为 [width, height]
|
|
37
|
+
* @param {string} image - 图片的 URL 地址
|
|
38
|
+
* @param {[number, number]} imageSize - 图标所用图片的大小,格式为 [width, height]
|
|
39
|
+
* @param {[number, number]} imageOffset - 图标取图的偏移量,格式为 [x, y]
|
|
40
|
+
*/
|
|
41
|
+
createIcon(size, image, imageSize, imageOffset = [0, 0]) {
|
|
42
|
+
return new this.AMap.Icon({
|
|
43
|
+
// 图标尺寸
|
|
44
|
+
size: this.Size(...size),
|
|
45
|
+
// 图标的取图地址
|
|
46
|
+
image: image,
|
|
47
|
+
// 图标所用图片大小
|
|
48
|
+
imageSize: this.Size(...imageSize),
|
|
49
|
+
// 图标取图偏移量
|
|
50
|
+
imageOffset: this.Pixel(...imageOffset),
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* 地物对象的像素尺寸
|
|
55
|
+
* @param {number} width 宽度
|
|
56
|
+
* @param {number} height 高度
|
|
57
|
+
*/
|
|
58
|
+
Size(width, height) {
|
|
59
|
+
return new this.AMap.Size(width, height);
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* 像素坐标,确定地图上的一个像素点。
|
|
63
|
+
* @param {number} x
|
|
64
|
+
* @param {number} y
|
|
65
|
+
*/
|
|
66
|
+
Pixel(x, y) {
|
|
67
|
+
return new this.AMap.Pixel(x, y);
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* 经纬度坐标,用来描述地图上的一个点位置
|
|
71
|
+
* @param {Number} lng 经度值
|
|
72
|
+
* @param {Number} lat 纬度值
|
|
73
|
+
* @param {boolean} noWrap 是否自动将经度值修正到 [-180,180] 区间内
|
|
74
|
+
*/
|
|
75
|
+
LngLat(lng, lat, noWrap = false) {
|
|
76
|
+
return new this.AMap.LngLat(lng, lat, noWrap);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
//TODO 海量点数据
|
|
80
|
+
createLabelLayer({
|
|
81
|
+
zoom = [1, 20],
|
|
82
|
+
zIndex = 1000,
|
|
83
|
+
collision = true,
|
|
84
|
+
layerClassName,
|
|
85
|
+
...rest
|
|
86
|
+
}) {
|
|
87
|
+
const labelLayer = new this.AMap.LabelsLayer({
|
|
88
|
+
zIndex,
|
|
89
|
+
collision,
|
|
90
|
+
zoom,
|
|
91
|
+
...rest,
|
|
92
|
+
});
|
|
93
|
+
labelLayer.setMap(this.map);
|
|
94
|
+
// HACK: labelLayer获取图层节点方式与原来不同,获取可以抽象marker图层, labelLayer图层,实现多态
|
|
95
|
+
// this.overlayGroupManagerMap.set(layerClassName,labelLayer);
|
|
96
|
+
return labelLayer;
|
|
97
|
+
},
|
|
98
|
+
// 创建labelMarker标注
|
|
99
|
+
createLabelLayerMarker({ icon, text, position, ...rest }) {
|
|
100
|
+
const label = new this.AMap.LabelMarker({
|
|
101
|
+
icon: icon,
|
|
102
|
+
text: text,
|
|
103
|
+
position: position,
|
|
104
|
+
...rest,
|
|
105
|
+
});
|
|
106
|
+
return label;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
createMarkerCluster(
|
|
110
|
+
points,
|
|
111
|
+
{ _renderClusterMarker, _renderMarker, gridSize }
|
|
112
|
+
) {
|
|
113
|
+
return new AMap.MarkerCluster(this.map, points, {
|
|
114
|
+
gridSize: gridSize, // 设置网格像素大小
|
|
115
|
+
renderClusterMarker: _renderClusterMarker, // 自定义聚合点样式
|
|
116
|
+
renderMarker: _renderMarker, // 自定义非聚合点样式
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
/*
|
|
120
|
+
创建点位信息窗体
|
|
121
|
+
*/
|
|
122
|
+
createInfoWindow({
|
|
123
|
+
content,
|
|
124
|
+
isCustom = true,
|
|
125
|
+
closeWhenClickMap = true,
|
|
126
|
+
...rest
|
|
127
|
+
}) {
|
|
128
|
+
return new this.AMap.InfoWindow({
|
|
129
|
+
content: content,
|
|
130
|
+
isCustom,
|
|
131
|
+
closeWhenClickMap: closeWhenClickMap,
|
|
132
|
+
...rest,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
/*
|
|
136
|
+
清楚地图所有信息窗体
|
|
137
|
+
*/
|
|
138
|
+
clearInfoWindow() {
|
|
139
|
+
this.map.clearInfoWindow();
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
//[ ] gdHelper.js中this.map.xxx得方法可以转移到gdUtils.js实例上,mapUtils
|
|
143
|
+
/* 打开高德信息弹框 */
|
|
144
|
+
openInfoWindow(infoWindow, ...rest) {
|
|
145
|
+
infoWindow.open(this.map, ...rest);
|
|
146
|
+
},
|
|
147
|
+
// 绘制线路
|
|
148
|
+
drawPolyline(paths) {
|
|
149
|
+
return new this.AMap.Polyline({
|
|
150
|
+
map: this.map,
|
|
151
|
+
...paths,
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
clearOverlays() {
|
|
156
|
+
this.map.clearMap(); // 清除地图上的所有覆盖物
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
removeSingleOverlay(overlay) {
|
|
160
|
+
this.map.remove(overlay); // 清除地图上某个覆盖物
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* 创建高德地图驾车导航
|
|
164
|
+
* @param {Object} options 导航配置
|
|
165
|
+
* @returns {AMap.Driving} 导航对象
|
|
166
|
+
*/
|
|
167
|
+
createAMapDriving(options) {
|
|
168
|
+
return new this.AMap.Driving(options);
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* 创建高德地图标注
|
|
172
|
+
* @param {Object} options 标注配置
|
|
173
|
+
* @returns {AMap.Marker} 标注对象
|
|
174
|
+
*/
|
|
175
|
+
createAMapMarker(options) {
|
|
176
|
+
return new this.AMap.Marker({
|
|
177
|
+
map: this.map,
|
|
178
|
+
...options,
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* 创建高德地图折线
|
|
183
|
+
* @param {Object} options 折线配置
|
|
184
|
+
* @returns {AMap.Polyline} 折线对象
|
|
185
|
+
*/
|
|
186
|
+
createAMapPolyline(options) {
|
|
187
|
+
return new this.AMap.Polyline({
|
|
188
|
+
map: this.map,
|
|
189
|
+
...options,
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export default gdHelperMixin;
|
package/src/gdMap/gdHelper.ts
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
const gdHelperMixin = {
|
|
2
|
-
/**
|
|
3
|
-
* 创建高德地图标注
|
|
4
|
-
* @param {AMap.MarkerOptions} options 标注配置
|
|
5
|
-
* @returns {AMap.Marker} 标注对象
|
|
6
|
-
*/
|
|
7
|
-
createAMapMarker(options: AMap.MarkerOptions): AMap.Marker {
|
|
8
|
-
return new AMap.Marker({
|
|
9
|
-
...options,
|
|
10
|
-
});
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* 创建一个图标
|
|
15
|
-
* @param {[number, number]} size - 图标尺寸,格式为 [width, height]
|
|
16
|
-
* @param {string} image - 图片的 URL 地址
|
|
17
|
-
* @param {[number, number]} imageSize - 图标所用图片的大小,格式为 [width, height]
|
|
18
|
-
* @param {[number, number]} imageOffset - 图标取图的偏移量,格式为 [x, y]
|
|
19
|
-
* @returns {AMap.Icon} 图标对象
|
|
20
|
-
*/
|
|
21
|
-
createIcon(opts: {
|
|
22
|
-
size: [number, number];
|
|
23
|
-
image: string;
|
|
24
|
-
imageSize: [number, number];
|
|
25
|
-
imageOffset: [number, number];
|
|
26
|
-
}): AMap.Icon {
|
|
27
|
-
return new AMap.Icon({
|
|
28
|
-
size: this.Size(...opts.size),
|
|
29
|
-
image: opts.image,
|
|
30
|
-
imageSize: this.Size(...opts.imageSize),
|
|
31
|
-
imageOffset: this.Pixel(...opts.imageOffset),
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 地物对象的像素尺寸
|
|
37
|
-
* @param {number} width 宽度
|
|
38
|
-
* @param {number} height 高度
|
|
39
|
-
* @returns {AMap.Size} 尺寸对象
|
|
40
|
-
*/
|
|
41
|
-
Size(width: number, height: number): AMap.Size {
|
|
42
|
-
return new AMap.Size(width, height);
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 像素坐标,确定地图上的一个像素点
|
|
47
|
-
* @param {number} x x坐标
|
|
48
|
-
* @param {number} y y坐标
|
|
49
|
-
* @returns {AMap.Pixel} 像素对象
|
|
50
|
-
*/
|
|
51
|
-
Pixel(...rest: [number, number]): AMap.Pixel {
|
|
52
|
-
return new AMap.Pixel(...rest);
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 经纬度坐标,用来描述地图上的一个点位置
|
|
57
|
-
* @param {number} lng 经度值
|
|
58
|
-
* @param {number} lat 纬度值
|
|
59
|
-
* @param {boolean} noWrap 是否不进行标准化处理
|
|
60
|
-
* @returns {AMap.LngLat} 经纬度对象
|
|
61
|
-
*/
|
|
62
|
-
LngLat(lng: number, lat: number, noWrap?: boolean): AMap.LngLat {
|
|
63
|
-
return new AMap.LngLat(lng, lat, noWrap);
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
创建点位信息窗体
|
|
68
|
-
*/
|
|
69
|
-
createAMapInfoWindow(opts: ConstructorParameters<typeof AMap.InfoWindow>[0]) {
|
|
70
|
-
const defIsCustom = true;
|
|
71
|
-
const defCloseWhenClickMap = true;
|
|
72
|
-
const {
|
|
73
|
-
isCustom = defIsCustom,
|
|
74
|
-
closeWhenClickMap = defCloseWhenClickMap,
|
|
75
|
-
...rest
|
|
76
|
-
} = opts!;
|
|
77
|
-
return new AMap.InfoWindow({
|
|
78
|
-
isCustom,
|
|
79
|
-
closeWhenClickMap,
|
|
80
|
-
...rest,
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export default gdHelperMixin;
|
|
1
|
+
const gdHelperMixin = {
|
|
2
|
+
/**
|
|
3
|
+
* 创建高德地图标注
|
|
4
|
+
* @param {AMap.MarkerOptions} options 标注配置
|
|
5
|
+
* @returns {AMap.Marker} 标注对象
|
|
6
|
+
*/
|
|
7
|
+
createAMapMarker(options: AMap.MarkerOptions): AMap.Marker {
|
|
8
|
+
return new AMap.Marker({
|
|
9
|
+
...options,
|
|
10
|
+
});
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 创建一个图标
|
|
15
|
+
* @param {[number, number]} size - 图标尺寸,格式为 [width, height]
|
|
16
|
+
* @param {string} image - 图片的 URL 地址
|
|
17
|
+
* @param {[number, number]} imageSize - 图标所用图片的大小,格式为 [width, height]
|
|
18
|
+
* @param {[number, number]} imageOffset - 图标取图的偏移量,格式为 [x, y]
|
|
19
|
+
* @returns {AMap.Icon} 图标对象
|
|
20
|
+
*/
|
|
21
|
+
createIcon(opts: {
|
|
22
|
+
size: [number, number];
|
|
23
|
+
image: string;
|
|
24
|
+
imageSize: [number, number];
|
|
25
|
+
imageOffset: [number, number];
|
|
26
|
+
}): AMap.Icon {
|
|
27
|
+
return new AMap.Icon({
|
|
28
|
+
size: this.Size(...opts.size),
|
|
29
|
+
image: opts.image,
|
|
30
|
+
imageSize: this.Size(...opts.imageSize),
|
|
31
|
+
imageOffset: this.Pixel(...opts.imageOffset),
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 地物对象的像素尺寸
|
|
37
|
+
* @param {number} width 宽度
|
|
38
|
+
* @param {number} height 高度
|
|
39
|
+
* @returns {AMap.Size} 尺寸对象
|
|
40
|
+
*/
|
|
41
|
+
Size(width: number, height: number): AMap.Size {
|
|
42
|
+
return new AMap.Size(width, height);
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 像素坐标,确定地图上的一个像素点
|
|
47
|
+
* @param {number} x x坐标
|
|
48
|
+
* @param {number} y y坐标
|
|
49
|
+
* @returns {AMap.Pixel} 像素对象
|
|
50
|
+
*/
|
|
51
|
+
Pixel(...rest: [number, number]): AMap.Pixel {
|
|
52
|
+
return new AMap.Pixel(...rest);
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 经纬度坐标,用来描述地图上的一个点位置
|
|
57
|
+
* @param {number} lng 经度值
|
|
58
|
+
* @param {number} lat 纬度值
|
|
59
|
+
* @param {boolean} noWrap 是否不进行标准化处理
|
|
60
|
+
* @returns {AMap.LngLat} 经纬度对象
|
|
61
|
+
*/
|
|
62
|
+
LngLat(lng: number, lat: number, noWrap?: boolean): AMap.LngLat {
|
|
63
|
+
return new AMap.LngLat(lng, lat, noWrap);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
创建点位信息窗体
|
|
68
|
+
*/
|
|
69
|
+
createAMapInfoWindow(opts: ConstructorParameters<typeof AMap.InfoWindow>[0]) {
|
|
70
|
+
const defIsCustom = true;
|
|
71
|
+
const defCloseWhenClickMap = true;
|
|
72
|
+
const {
|
|
73
|
+
isCustom = defIsCustom,
|
|
74
|
+
closeWhenClickMap = defCloseWhenClickMap,
|
|
75
|
+
...rest
|
|
76
|
+
} = opts!;
|
|
77
|
+
return new AMap.InfoWindow({
|
|
78
|
+
isCustom,
|
|
79
|
+
closeWhenClickMap,
|
|
80
|
+
...rest,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default gdHelperMixin;
|