gdmap-utils 1.1.6 → 1.1.8

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.
@@ -1,67 +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
- 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;