@heycar/heycars-map 2.4.0 → 2.4.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/README.md +12 -0
- package/dist/v2/api/geometry.d.ts +2 -0
- package/dist/v2/api/geometry.js +16 -0
- package/dist/v2/business-components/BusinessRecomendPlaceMap/useCacheCenterPlace.d.ts +0 -1
- package/dist/v2/business-components/BusinessRecomendPlaceMap/useCacheCenterPlace.js +4 -1
- package/dist/v2/chunks/gcoord.esm-bundler.3f2f1369.js +514 -0
- package/dist/v2/components/Gmap/Gmap.js +0 -7
- package/dist/v2/hooks/useMapCoordinatify.js +5 -2
- package/dist/v2/hooks/useMapGCJ02.d.ts +3 -0
- package/dist/v2/hooks/useMapGCJ02.js +32 -513
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +2 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v3/api/geometry.d.ts +2 -0
- package/dist/v3/api/geometry.js +16 -0
- package/dist/v3/business-components/BusinessRecomendPlaceMap/useCacheCenterPlace.d.ts +0 -1
- package/dist/v3/business-components/BusinessRecomendPlaceMap/useCacheCenterPlace.js +4 -1
- package/dist/v3/chunks/gcoord.esm-bundler.3f2f1369.js +514 -0
- package/dist/v3/components/Gmap/Gmap.js +0 -7
- package/dist/v3/hooks/useMapCoordinatify.js +5 -2
- package/dist/v3/hooks/useMapGCJ02.d.ts +3 -0
- package/dist/v3/hooks/useMapGCJ02.js +32 -513
- package/dist/v3/index.d.ts +1 -0
- package/dist/v3/index.js +2 -0
- package/dist/v3/utils/log.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -655,3 +655,15 @@ enableAuxiliaryGraspRoad 模式适用场景:
|
|
|
655
655
|
3. 会将供应商提供的司机位置显示为蓝色标记,辅助观察供应商提供的司机位置。
|
|
656
656
|
4. 会显示一条黑色的路径,表示将供应商提供的位置纠偏以后的路径。
|
|
657
657
|
5. enableAuxiliaryGraspRoad 模式下,为了方便测试,取消了屏幕 15 秒自动调整功能。
|
|
658
|
+
|
|
659
|
+
#### 下面是地图导出的一些基本工具
|
|
660
|
+
|
|
661
|
+
```ts
|
|
662
|
+
import { isCoordinatePointEqual } from "@heycar/heycars-map";
|
|
663
|
+
|
|
664
|
+
// 比较两个带有坐标类型的点是否为同一个点
|
|
665
|
+
isCoordinatePointEqual(
|
|
666
|
+
{ type: "gcj02", lng: 114.215114, lat: 22.215972 },
|
|
667
|
+
{ type: "wgs84", lng: 114.21016180538568, lat: 22.219570659901557 },
|
|
668
|
+
) === true;
|
|
669
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { e as exported } from "../chunks/gcoord.esm-bundler.3f2f1369.js";
|
|
2
|
+
const GCOORD_ACCURCY_RANGE = 1e-6;
|
|
3
|
+
function isCoordinatePointEqual(p1, p2) {
|
|
4
|
+
if (!p2)
|
|
5
|
+
return false;
|
|
6
|
+
if (p1.type === p2.type)
|
|
7
|
+
return p1.lng === p2.lng && p1.lat === p2.lat;
|
|
8
|
+
const { lng: x1, lat: y1 } = p1.type === "gcj02" ? p1 : p2;
|
|
9
|
+
const wgsPoint = p1.type === "gcj02" ? p2 : p1;
|
|
10
|
+
const { lng, lat } = wgsPoint;
|
|
11
|
+
const [x2, y2] = exported.transform([lng, lat], exported.WGS84, exported.GCJ02);
|
|
12
|
+
return Math.abs(x1 - x2) <= GCOORD_ACCURCY_RANGE && Math.abs(y1 - y2) <= GCOORD_ACCURCY_RANGE;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
isCoordinatePointEqual
|
|
16
|
+
};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { reactive } from "vue-demi";
|
|
2
2
|
import { apiGetCenterPlaceFromCache } from "../../api/browser.js";
|
|
3
3
|
import { apiMemoryShouldSkipByKey } from "../../api/memory.js";
|
|
4
|
+
import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
|
|
4
5
|
import { maybeFunctionToFunction, lnglat2point } from "../../utils/transform.js";
|
|
5
6
|
const IS_FIRST_LOAD_KEY = "IS_FIRST_LOAD_KEY";
|
|
6
7
|
const useCacheCenterPlace = (props) => {
|
|
7
8
|
const { geoLoadingTitle, emptyTitle } = props;
|
|
8
9
|
const isFirstLoad = !apiMemoryShouldSkipByKey(IS_FIRST_LOAD_KEY);
|
|
9
10
|
const getDefaultCenterPlace = maybeFunctionToFunction(props.defaultCenterPlace);
|
|
11
|
+
const { unCoordinatifyPlace } = useMapCoordinatify();
|
|
12
|
+
const inputDefaultCenterPlace = getDefaultCenterPlace == null ? void 0 : getDefaultCenterPlace(apiGetCenterPlaceFromCache());
|
|
10
13
|
const defaultCenterPlace = {
|
|
11
14
|
lng: 0,
|
|
12
15
|
lat: 0,
|
|
13
16
|
name: emptyTitle,
|
|
14
17
|
displayName: emptyTitle,
|
|
15
|
-
...
|
|
18
|
+
...inputDefaultCenterPlace ? unCoordinatifyPlace(inputDefaultCenterPlace) : void 0
|
|
16
19
|
};
|
|
17
20
|
const geoDefaultPosition = defaultCenterPlace ? lnglat2point(defaultCenterPlace) : [0, 0];
|
|
18
21
|
const centerPlace = reactive({
|
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @preserve
|
|
3
|
+
* gcoord 1.0.5, geographic coordinate library
|
|
4
|
+
* Copyright (c) 2023 Jiulong Hu <me@hujiulong.com>
|
|
5
|
+
*/
|
|
6
|
+
const { sin: sin$1, cos: cos$1, sqrt: sqrt$1, abs: abs$1, PI: PI$1 } = Math;
|
|
7
|
+
const a = 6378245;
|
|
8
|
+
const ee = 0.006693421622965823;
|
|
9
|
+
function isInChinaBbox(lon, lat) {
|
|
10
|
+
return lon >= 72.004 && lon <= 137.8347 && lat >= 0.8293 && lat <= 55.8271;
|
|
11
|
+
}
|
|
12
|
+
function transformLat(x, y) {
|
|
13
|
+
let ret = -100 + 2 * x + 3 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt$1(abs$1(x));
|
|
14
|
+
ret += (20 * sin$1(6 * x * PI$1) + 20 * sin$1(2 * x * PI$1)) * 2 / 3;
|
|
15
|
+
ret += (20 * sin$1(y * PI$1) + 40 * sin$1(y / 3 * PI$1)) * 2 / 3;
|
|
16
|
+
ret += (160 * sin$1(y / 12 * PI$1) + 320 * sin$1(y * PI$1 / 30)) * 2 / 3;
|
|
17
|
+
return ret;
|
|
18
|
+
}
|
|
19
|
+
function transformLon(x, y) {
|
|
20
|
+
let ret = 300 + x + 2 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt$1(abs$1(x));
|
|
21
|
+
ret += (20 * sin$1(6 * x * PI$1) + 20 * sin$1(2 * x * PI$1)) * 2 / 3;
|
|
22
|
+
ret += (20 * sin$1(x * PI$1) + 40 * sin$1(x / 3 * PI$1)) * 2 / 3;
|
|
23
|
+
ret += (150 * sin$1(x / 12 * PI$1) + 300 * sin$1(x / 30 * PI$1)) * 2 / 3;
|
|
24
|
+
return ret;
|
|
25
|
+
}
|
|
26
|
+
function delta(lon, lat) {
|
|
27
|
+
let dLon = transformLon(lon - 105, lat - 35);
|
|
28
|
+
let dLat = transformLat(lon - 105, lat - 35);
|
|
29
|
+
const radLat = lat / 180 * PI$1;
|
|
30
|
+
let magic = sin$1(radLat);
|
|
31
|
+
magic = 1 - ee * magic * magic;
|
|
32
|
+
const sqrtMagic = sqrt$1(magic);
|
|
33
|
+
dLon = dLon * 180 / (a / sqrtMagic * cos$1(radLat) * PI$1);
|
|
34
|
+
dLat = dLat * 180 / (a * (1 - ee) / (magic * sqrtMagic) * PI$1);
|
|
35
|
+
return [dLon, dLat];
|
|
36
|
+
}
|
|
37
|
+
function WGS84ToGCJ02(coord) {
|
|
38
|
+
const [lon, lat] = coord;
|
|
39
|
+
if (!isInChinaBbox(lon, lat))
|
|
40
|
+
return [lon, lat];
|
|
41
|
+
const d = delta(lon, lat);
|
|
42
|
+
return [lon + d[0], lat + d[1]];
|
|
43
|
+
}
|
|
44
|
+
function GCJ02ToWGS84(coord) {
|
|
45
|
+
const [lon, lat] = coord;
|
|
46
|
+
if (!isInChinaBbox(lon, lat))
|
|
47
|
+
return [lon, lat];
|
|
48
|
+
let [wgsLon, wgsLat] = [lon, lat];
|
|
49
|
+
let tempPoint = WGS84ToGCJ02([wgsLon, wgsLat]);
|
|
50
|
+
let dx = tempPoint[0] - lon;
|
|
51
|
+
let dy = tempPoint[1] - lat;
|
|
52
|
+
while (abs$1(dx) > 1e-6 || abs$1(dy) > 1e-6) {
|
|
53
|
+
wgsLon -= dx;
|
|
54
|
+
wgsLat -= dy;
|
|
55
|
+
tempPoint = WGS84ToGCJ02([wgsLon, wgsLat]);
|
|
56
|
+
dx = tempPoint[0] - lon;
|
|
57
|
+
dy = tempPoint[1] - lat;
|
|
58
|
+
}
|
|
59
|
+
return [wgsLon, wgsLat];
|
|
60
|
+
}
|
|
61
|
+
const { sin, cos, atan2, sqrt, PI } = Math;
|
|
62
|
+
const baiduFactor = PI * 3e3 / 180;
|
|
63
|
+
function BD09ToGCJ02(coord) {
|
|
64
|
+
const [lon, lat] = coord;
|
|
65
|
+
const x = lon - 65e-4;
|
|
66
|
+
const y = lat - 6e-3;
|
|
67
|
+
const z = sqrt(x * x + y * y) - 2e-5 * sin(y * baiduFactor);
|
|
68
|
+
const theta = atan2(y, x) - 3e-6 * cos(x * baiduFactor);
|
|
69
|
+
const newLon = z * cos(theta);
|
|
70
|
+
const newLat = z * sin(theta);
|
|
71
|
+
return [newLon, newLat];
|
|
72
|
+
}
|
|
73
|
+
function GCJ02ToBD09(coord) {
|
|
74
|
+
const [lon, lat] = coord;
|
|
75
|
+
const x = lon;
|
|
76
|
+
const y = lat;
|
|
77
|
+
const z = sqrt(x * x + y * y) + 2e-5 * sin(y * baiduFactor);
|
|
78
|
+
const theta = atan2(y, x) + 3e-6 * cos(x * baiduFactor);
|
|
79
|
+
const newLon = z * cos(theta) + 65e-4;
|
|
80
|
+
const newLat = z * sin(theta) + 6e-3;
|
|
81
|
+
return [newLon, newLat];
|
|
82
|
+
}
|
|
83
|
+
const R2D = 180 / Math.PI;
|
|
84
|
+
const D2R = Math.PI / 180;
|
|
85
|
+
const A = 6378137;
|
|
86
|
+
const MAXEXTENT = 20037508342789244e-9;
|
|
87
|
+
function ESPG3857ToWGS84(xy) {
|
|
88
|
+
return [
|
|
89
|
+
xy[0] * R2D / A,
|
|
90
|
+
(Math.PI * 0.5 - 2 * Math.atan(Math.exp(-xy[1] / A))) * R2D
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
function WGS84ToEPSG3857(lonLat) {
|
|
94
|
+
const adjusted = Math.abs(lonLat[0]) <= 180 ? lonLat[0] : lonLat[0] - (lonLat[0] < 0 ? -1 : 1) * 360;
|
|
95
|
+
const xy = [
|
|
96
|
+
A * adjusted * D2R,
|
|
97
|
+
A * Math.log(Math.tan(Math.PI * 0.25 + 0.5 * lonLat[1] * D2R))
|
|
98
|
+
];
|
|
99
|
+
if (xy[0] > MAXEXTENT)
|
|
100
|
+
xy[0] = MAXEXTENT;
|
|
101
|
+
if (xy[0] < -MAXEXTENT)
|
|
102
|
+
xy[0] = -MAXEXTENT;
|
|
103
|
+
if (xy[1] > MAXEXTENT)
|
|
104
|
+
xy[1] = MAXEXTENT;
|
|
105
|
+
if (xy[1] < -MAXEXTENT)
|
|
106
|
+
xy[1] = -MAXEXTENT;
|
|
107
|
+
return xy;
|
|
108
|
+
}
|
|
109
|
+
const { abs } = Math;
|
|
110
|
+
const MCBAND = [1289059486e-2, 836237787e-2, 5591021, 348198983e-2, 167804312e-2, 0];
|
|
111
|
+
const LLBAND = [75, 60, 45, 30, 15, 0];
|
|
112
|
+
const MC2LL = [
|
|
113
|
+
[
|
|
114
|
+
1410526172116255e-23,
|
|
115
|
+
898305509648872e-20,
|
|
116
|
+
-1.9939833816331,
|
|
117
|
+
200.9824383106796,
|
|
118
|
+
-187.2403703815547,
|
|
119
|
+
91.6087516669843,
|
|
120
|
+
-23.38765649603339,
|
|
121
|
+
2.57121317296198,
|
|
122
|
+
-0.03801003308653,
|
|
123
|
+
173379812e-1
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
-7435856389565537e-24,
|
|
127
|
+
8983055097726239e-21,
|
|
128
|
+
-0.78625201886289,
|
|
129
|
+
96.32687599759846,
|
|
130
|
+
-1.85204757529826,
|
|
131
|
+
-59.36935905485877,
|
|
132
|
+
47.40033549296737,
|
|
133
|
+
-16.50741931063887,
|
|
134
|
+
2.28786674699375,
|
|
135
|
+
1026014486e-2
|
|
136
|
+
],
|
|
137
|
+
[
|
|
138
|
+
-3030883460898826e-23,
|
|
139
|
+
898305509983578e-20,
|
|
140
|
+
0.30071316287616,
|
|
141
|
+
59.74293618442277,
|
|
142
|
+
7.357984074871,
|
|
143
|
+
-25.38371002664745,
|
|
144
|
+
13.45380521110908,
|
|
145
|
+
-3.29883767235584,
|
|
146
|
+
0.32710905363475,
|
|
147
|
+
685681737e-2
|
|
148
|
+
],
|
|
149
|
+
[
|
|
150
|
+
-1981981304930552e-23,
|
|
151
|
+
8983055099779535e-21,
|
|
152
|
+
0.03278182852591,
|
|
153
|
+
40.31678527705744,
|
|
154
|
+
0.65659298677277,
|
|
155
|
+
-4.44255534477492,
|
|
156
|
+
0.85341911805263,
|
|
157
|
+
0.12923347998204,
|
|
158
|
+
-0.04625736007561,
|
|
159
|
+
448277706e-2
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
309191371068437e-23,
|
|
163
|
+
8983055096812155e-21,
|
|
164
|
+
6995724062e-14,
|
|
165
|
+
23.10934304144901,
|
|
166
|
+
-23663490511e-14,
|
|
167
|
+
-0.6321817810242,
|
|
168
|
+
-0.00663494467273,
|
|
169
|
+
0.03430082397953,
|
|
170
|
+
-0.00466043876332,
|
|
171
|
+
25551644e-1
|
|
172
|
+
],
|
|
173
|
+
[
|
|
174
|
+
2890871144776878e-24,
|
|
175
|
+
8983055095805407e-21,
|
|
176
|
+
-3068298e-14,
|
|
177
|
+
7.47137025468032,
|
|
178
|
+
-353937994e-14,
|
|
179
|
+
-0.02145144861037,
|
|
180
|
+
-1234426596e-14,
|
|
181
|
+
10322952773e-14,
|
|
182
|
+
-323890364e-14,
|
|
183
|
+
826088.5
|
|
184
|
+
]
|
|
185
|
+
];
|
|
186
|
+
const LL2MC = [
|
|
187
|
+
[
|
|
188
|
+
-0.0015702102444,
|
|
189
|
+
111320.7020616939,
|
|
190
|
+
1704480524535203,
|
|
191
|
+
-10338987376042340,
|
|
192
|
+
26112667856603880,
|
|
193
|
+
-35149669176653700,
|
|
194
|
+
26595700718403920,
|
|
195
|
+
-10725012454188240,
|
|
196
|
+
1800819912950474,
|
|
197
|
+
82.5
|
|
198
|
+
],
|
|
199
|
+
[
|
|
200
|
+
8277824516172526e-19,
|
|
201
|
+
111320.7020463578,
|
|
202
|
+
6477955746671607e-7,
|
|
203
|
+
-4082003173641316e-6,
|
|
204
|
+
1077490566351142e-5,
|
|
205
|
+
-1517187553151559e-5,
|
|
206
|
+
1205306533862167e-5,
|
|
207
|
+
-5124939663577472e-6,
|
|
208
|
+
9133119359512032e-7,
|
|
209
|
+
67.5
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
0.00337398766765,
|
|
213
|
+
111320.7020202162,
|
|
214
|
+
4481351045890365e-9,
|
|
215
|
+
-2339375119931662e-8,
|
|
216
|
+
7968221547186455e-8,
|
|
217
|
+
-1159649932797253e-7,
|
|
218
|
+
9723671115602145e-8,
|
|
219
|
+
-4366194633752821e-8,
|
|
220
|
+
8477230501135234e-9,
|
|
221
|
+
52.5
|
|
222
|
+
],
|
|
223
|
+
[
|
|
224
|
+
0.00220636496208,
|
|
225
|
+
111320.7020209128,
|
|
226
|
+
51751.86112841131,
|
|
227
|
+
3796837749470245e-9,
|
|
228
|
+
992013.7397791013,
|
|
229
|
+
-122195221711287e-8,
|
|
230
|
+
1340652697009075e-9,
|
|
231
|
+
-620943.6990984312,
|
|
232
|
+
144416.9293806241,
|
|
233
|
+
37.5
|
|
234
|
+
],
|
|
235
|
+
[
|
|
236
|
+
-3441963504368392e-19,
|
|
237
|
+
111320.7020576856,
|
|
238
|
+
278.2353980772752,
|
|
239
|
+
2485758690035394e-9,
|
|
240
|
+
6070.750963243378,
|
|
241
|
+
54821.18345352118,
|
|
242
|
+
9540.606633304236,
|
|
243
|
+
-2710.55326746645,
|
|
244
|
+
1405.483844121726,
|
|
245
|
+
22.5
|
|
246
|
+
],
|
|
247
|
+
[
|
|
248
|
+
-3218135878613132e-19,
|
|
249
|
+
111320.7020701615,
|
|
250
|
+
0.00369383431289,
|
|
251
|
+
823725.6402795718,
|
|
252
|
+
0.46104986909093,
|
|
253
|
+
2351.343141331292,
|
|
254
|
+
1.58060784298199,
|
|
255
|
+
8.77738589078284,
|
|
256
|
+
0.37238884252424,
|
|
257
|
+
7.45
|
|
258
|
+
]
|
|
259
|
+
];
|
|
260
|
+
function transform$1(x, y, factors) {
|
|
261
|
+
const cc = abs(y) / factors[9];
|
|
262
|
+
let xt = factors[0] + factors[1] * abs(x);
|
|
263
|
+
let yt = factors[2] + factors[3] * cc + factors[4] * Math.pow(cc, 2) + factors[5] * Math.pow(cc, 3) + factors[6] * Math.pow(cc, 4) + factors[7] * Math.pow(cc, 5) + factors[8] * Math.pow(cc, 6);
|
|
264
|
+
xt *= x < 0 ? -1 : 1;
|
|
265
|
+
yt *= y < 0 ? -1 : 1;
|
|
266
|
+
return [xt, yt];
|
|
267
|
+
}
|
|
268
|
+
function BD09toBD09MC(coord) {
|
|
269
|
+
const [lng, lat] = coord;
|
|
270
|
+
let factors = [];
|
|
271
|
+
for (let i = 0; i < LLBAND.length; i++) {
|
|
272
|
+
if (abs(lat) > LLBAND[i]) {
|
|
273
|
+
factors = LL2MC[i];
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return transform$1(lng, lat, factors);
|
|
278
|
+
}
|
|
279
|
+
function BD09MCtoBD09(coord) {
|
|
280
|
+
const [x, y] = coord;
|
|
281
|
+
let factors = [];
|
|
282
|
+
for (let i = 0; i < MCBAND.length; i++) {
|
|
283
|
+
if (y >= MCBAND[i]) {
|
|
284
|
+
factors = MC2LL[i];
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return transform$1(x, y, factors);
|
|
289
|
+
}
|
|
290
|
+
function assert(condition, msg) {
|
|
291
|
+
if (!condition)
|
|
292
|
+
throw new Error(msg);
|
|
293
|
+
}
|
|
294
|
+
function isArray(input) {
|
|
295
|
+
return !!input && Object.prototype.toString.call(input) === "[object Array]";
|
|
296
|
+
}
|
|
297
|
+
function isNumber(input) {
|
|
298
|
+
return !isNaN(Number(input)) && input !== null && !isArray(input);
|
|
299
|
+
}
|
|
300
|
+
function compose(...funcs) {
|
|
301
|
+
const start = funcs.length - 1;
|
|
302
|
+
return function(...args) {
|
|
303
|
+
let i = start;
|
|
304
|
+
let result = funcs[start].apply(null, args);
|
|
305
|
+
while (i--)
|
|
306
|
+
result = funcs[i].call(null, result);
|
|
307
|
+
return result;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function coordEach(geojson, callback, excludeWrapCoord = false) {
|
|
311
|
+
if (geojson === null)
|
|
312
|
+
return;
|
|
313
|
+
let j;
|
|
314
|
+
let k;
|
|
315
|
+
let l;
|
|
316
|
+
let geometry;
|
|
317
|
+
let coords;
|
|
318
|
+
let stopG;
|
|
319
|
+
let wrapShrink = 0;
|
|
320
|
+
let coordIndex = 0;
|
|
321
|
+
let geometryMaybeCollection;
|
|
322
|
+
let isGeometryCollection;
|
|
323
|
+
const { type } = geojson;
|
|
324
|
+
const isFeatureCollection = type === "FeatureCollection";
|
|
325
|
+
const isFeature = type === "Feature";
|
|
326
|
+
const stop = isFeatureCollection ? geojson.features.length : 1;
|
|
327
|
+
for (let featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
328
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
329
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
330
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
331
|
+
for (let geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
332
|
+
let multiFeatureIndex = 0;
|
|
333
|
+
let geometryIndex = 0;
|
|
334
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
335
|
+
if (geometry === null)
|
|
336
|
+
continue;
|
|
337
|
+
const geomType = geometry.type;
|
|
338
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
339
|
+
switch (geomType) {
|
|
340
|
+
case null:
|
|
341
|
+
break;
|
|
342
|
+
case "Point":
|
|
343
|
+
coords = geometry.coordinates;
|
|
344
|
+
if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
345
|
+
return false;
|
|
346
|
+
coordIndex++;
|
|
347
|
+
multiFeatureIndex++;
|
|
348
|
+
break;
|
|
349
|
+
case "LineString":
|
|
350
|
+
case "MultiPoint":
|
|
351
|
+
coords = geometry.coordinates;
|
|
352
|
+
for (j = 0; j < coords.length; j++) {
|
|
353
|
+
if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
354
|
+
return false;
|
|
355
|
+
coordIndex++;
|
|
356
|
+
if (geomType === "MultiPoint")
|
|
357
|
+
multiFeatureIndex++;
|
|
358
|
+
}
|
|
359
|
+
if (geomType === "LineString")
|
|
360
|
+
multiFeatureIndex++;
|
|
361
|
+
break;
|
|
362
|
+
case "Polygon":
|
|
363
|
+
case "MultiLineString":
|
|
364
|
+
coords = geometry.coordinates;
|
|
365
|
+
for (j = 0; j < coords.length; j++) {
|
|
366
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
367
|
+
if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
368
|
+
return false;
|
|
369
|
+
coordIndex++;
|
|
370
|
+
}
|
|
371
|
+
if (geomType === "MultiLineString")
|
|
372
|
+
multiFeatureIndex++;
|
|
373
|
+
if (geomType === "Polygon")
|
|
374
|
+
geometryIndex++;
|
|
375
|
+
}
|
|
376
|
+
if (geomType === "Polygon")
|
|
377
|
+
multiFeatureIndex++;
|
|
378
|
+
break;
|
|
379
|
+
case "MultiPolygon":
|
|
380
|
+
coords = geometry.coordinates;
|
|
381
|
+
for (j = 0; j < coords.length; j++) {
|
|
382
|
+
geometryIndex = 0;
|
|
383
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
384
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
385
|
+
if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
386
|
+
return false;
|
|
387
|
+
coordIndex++;
|
|
388
|
+
}
|
|
389
|
+
geometryIndex++;
|
|
390
|
+
}
|
|
391
|
+
multiFeatureIndex++;
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
case "GeometryCollection":
|
|
395
|
+
for (j = 0; j < geometry.geometries.length; j++) {
|
|
396
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
break;
|
|
400
|
+
default:
|
|
401
|
+
throw new Error("Unknown Geometry Type");
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
var CRSTypes;
|
|
407
|
+
(function(CRSTypes2) {
|
|
408
|
+
CRSTypes2["WGS84"] = "WGS84";
|
|
409
|
+
CRSTypes2["WGS1984"] = "WGS84";
|
|
410
|
+
CRSTypes2["EPSG4326"] = "WGS84";
|
|
411
|
+
CRSTypes2["GCJ02"] = "GCJ02";
|
|
412
|
+
CRSTypes2["AMap"] = "GCJ02";
|
|
413
|
+
CRSTypes2["BD09"] = "BD09";
|
|
414
|
+
CRSTypes2["BD09LL"] = "BD09";
|
|
415
|
+
CRSTypes2["Baidu"] = "BD09";
|
|
416
|
+
CRSTypes2["BMap"] = "BD09";
|
|
417
|
+
CRSTypes2["BD09MC"] = "BD09MC";
|
|
418
|
+
CRSTypes2["BD09Meter"] = "BD09MC";
|
|
419
|
+
CRSTypes2["EPSG3857"] = "EPSG3857";
|
|
420
|
+
CRSTypes2["EPSG900913"] = "EPSG3857";
|
|
421
|
+
CRSTypes2["EPSG102100"] = "EPSG3857";
|
|
422
|
+
CRSTypes2["WebMercator"] = "EPSG3857";
|
|
423
|
+
CRSTypes2["WM"] = "EPSG3857";
|
|
424
|
+
})(CRSTypes || (CRSTypes = {}));
|
|
425
|
+
const WGS84 = {
|
|
426
|
+
to: {
|
|
427
|
+
[CRSTypes.GCJ02]: WGS84ToGCJ02,
|
|
428
|
+
[CRSTypes.BD09]: compose(GCJ02ToBD09, WGS84ToGCJ02),
|
|
429
|
+
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09, WGS84ToGCJ02),
|
|
430
|
+
[CRSTypes.EPSG3857]: WGS84ToEPSG3857
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
const GCJ02 = {
|
|
434
|
+
to: {
|
|
435
|
+
[CRSTypes.WGS84]: GCJ02ToWGS84,
|
|
436
|
+
[CRSTypes.BD09]: GCJ02ToBD09,
|
|
437
|
+
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09),
|
|
438
|
+
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84)
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
const BD09 = {
|
|
442
|
+
to: {
|
|
443
|
+
[CRSTypes.WGS84]: compose(GCJ02ToWGS84, BD09ToGCJ02),
|
|
444
|
+
[CRSTypes.GCJ02]: BD09ToGCJ02,
|
|
445
|
+
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84, BD09ToGCJ02),
|
|
446
|
+
[CRSTypes.BD09MC]: BD09toBD09MC
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
const EPSG3857 = {
|
|
450
|
+
to: {
|
|
451
|
+
[CRSTypes.WGS84]: ESPG3857ToWGS84,
|
|
452
|
+
[CRSTypes.GCJ02]: compose(WGS84ToGCJ02, ESPG3857ToWGS84),
|
|
453
|
+
[CRSTypes.BD09]: compose(GCJ02ToBD09, WGS84ToGCJ02, ESPG3857ToWGS84),
|
|
454
|
+
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09, WGS84ToGCJ02, ESPG3857ToWGS84)
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
const BD09MC = {
|
|
458
|
+
to: {
|
|
459
|
+
[CRSTypes.WGS84]: compose(GCJ02ToWGS84, BD09ToGCJ02, BD09MCtoBD09),
|
|
460
|
+
[CRSTypes.GCJ02]: compose(BD09ToGCJ02, BD09MCtoBD09),
|
|
461
|
+
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84, BD09ToGCJ02, BD09MCtoBD09),
|
|
462
|
+
[CRSTypes.BD09]: BD09MCtoBD09
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
const crsMap = {
|
|
466
|
+
WGS84,
|
|
467
|
+
GCJ02,
|
|
468
|
+
BD09,
|
|
469
|
+
EPSG3857,
|
|
470
|
+
BD09MC
|
|
471
|
+
};
|
|
472
|
+
var crsMap$1 = crsMap;
|
|
473
|
+
function transform(input, crsFrom, crsTo) {
|
|
474
|
+
assert(!!input, "The args[0] input coordinate is required");
|
|
475
|
+
assert(!!crsFrom, "The args[1] original coordinate system is required");
|
|
476
|
+
assert(!!crsTo, "The args[2] target coordinate system is required");
|
|
477
|
+
if (crsFrom === crsTo)
|
|
478
|
+
return input;
|
|
479
|
+
const from = crsMap$1[crsFrom];
|
|
480
|
+
assert(!!from, `Invalid original coordinate system: ${crsFrom}`);
|
|
481
|
+
const to = from.to[crsTo];
|
|
482
|
+
assert(!!to, `Invalid target coordinate system: ${crsTo}`);
|
|
483
|
+
const type = typeof input;
|
|
484
|
+
assert(type === "string" || type === "object", `Invalid input coordinate type: ${type}`);
|
|
485
|
+
if (type === "string") {
|
|
486
|
+
try {
|
|
487
|
+
input = JSON.parse(input);
|
|
488
|
+
} catch (e) {
|
|
489
|
+
throw new Error(`Invalid input coordinate: ${input}`);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
let isPosition = false;
|
|
493
|
+
if (isArray(input)) {
|
|
494
|
+
assert(input.length >= 2, `Invalid input coordinate: ${input}`);
|
|
495
|
+
assert(isNumber(input[0]) && isNumber(input[1]), `Invalid input coordinate: ${input}`);
|
|
496
|
+
input = input.map(Number);
|
|
497
|
+
isPosition = true;
|
|
498
|
+
}
|
|
499
|
+
const convert = to;
|
|
500
|
+
if (isPosition)
|
|
501
|
+
return convert(input);
|
|
502
|
+
coordEach(input, (coord) => {
|
|
503
|
+
[coord[0], coord[1]] = convert(coord);
|
|
504
|
+
});
|
|
505
|
+
return input;
|
|
506
|
+
}
|
|
507
|
+
const exported = Object.assign(Object.assign({}, CRSTypes), {
|
|
508
|
+
// 兼容原来gcoord.WGS84的使用方式
|
|
509
|
+
CRSTypes,
|
|
510
|
+
transform
|
|
511
|
+
});
|
|
512
|
+
export {
|
|
513
|
+
exported as e
|
|
514
|
+
};
|
|
@@ -4,13 +4,11 @@ import { createElement } from "../../demi-polyfill/demi-polyfill.js";
|
|
|
4
4
|
import { provideGmap } from "../../hooks/useMap.js";
|
|
5
5
|
import { useMapEventSource } from "../../hooks/useMapEventSource.js";
|
|
6
6
|
import { useGmapGestureZoomCenter } from "../../hooks/useMapGestureZoomCenter.js";
|
|
7
|
-
import { useGmapTouchStartCenter } from "../../hooks/useMapTouchStartCenter.js";
|
|
8
7
|
import { useGmapWheelZoomCenter } from "../../hooks/useMapWheelZoomCenter.js";
|
|
9
8
|
import { useResizeObserver } from "../../hooks/useResizeObserver.js";
|
|
10
9
|
import { defineSetup } from "../../types/helper.js";
|
|
11
10
|
import { watchNoneImmediatePostEffectForDeepOption, watchPostEffectForGMapEvent } from "../../utils/compare.js";
|
|
12
11
|
import { OS_PLATFORM, detectOSPlatform } from "../../utils/platform.js";
|
|
13
|
-
import { vec2lnglat } from "../../utils/transform.js";
|
|
14
12
|
const Gmap_css_ts_vanilla = "";
|
|
15
13
|
var gmap = "_7anfuo0";
|
|
16
14
|
const Gmap = defineSetup("Gmap", function(props, { slots, emit, attrs }) {
|
|
@@ -42,16 +40,11 @@ const Gmap = defineSetup("Gmap", function(props, { slots, emit, attrs }) {
|
|
|
42
40
|
const elementRef = shallowRef();
|
|
43
41
|
const mapRef = shallowRef();
|
|
44
42
|
const { executeMapApi } = useMapEventSource();
|
|
45
|
-
const { touchstartCenterRef } = useGmapTouchStartCenter({ mapRef, elementRef });
|
|
46
43
|
const handleDrag = (name) => {
|
|
47
44
|
emit(name, { target: mapRef.value });
|
|
48
45
|
};
|
|
49
46
|
const handleZoom = (name) => {
|
|
50
|
-
var _a;
|
|
51
47
|
emit(name, { target: mapRef.value });
|
|
52
|
-
const center = touchstartCenterRef.value;
|
|
53
|
-
if (center)
|
|
54
|
-
(_a = mapRef.value) == null ? void 0 : _a.setCenter(vec2lnglat(center));
|
|
55
48
|
};
|
|
56
49
|
provideGmap(mapRef);
|
|
57
50
|
useGmapWheelZoomCenter({ mapRef, enableRef });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMapGCJ02 } from "./useMapGCJ02.js";
|
|
2
|
+
import { inChina } from "./useMapInChina.js";
|
|
2
3
|
function useMapCoordinatify() {
|
|
3
|
-
const { toCoordinateType, toLocalGcj02 } = useMapGCJ02();
|
|
4
|
+
const { toCoordinateType, toLocalGcj02, toLocalWgs84 } = useMapGCJ02();
|
|
4
5
|
const coordinatifyPoint = (value) => {
|
|
5
6
|
const [lng, lat] = value;
|
|
6
7
|
return { lng, lat, type: toCoordinateType(value) };
|
|
@@ -11,7 +12,9 @@ function useMapCoordinatify() {
|
|
|
11
12
|
if (type === inputType)
|
|
12
13
|
return [lng, lat];
|
|
13
14
|
if (type === "wgs84") {
|
|
14
|
-
|
|
15
|
+
if (!inChina([lng, lat]))
|
|
16
|
+
throw new Error(`国外经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
|
|
17
|
+
return toLocalWgs84([lng, lat]);
|
|
15
18
|
}
|
|
16
19
|
return toLocalGcj02([lng, lat]);
|
|
17
20
|
};
|
|
@@ -5,6 +5,7 @@ export declare const useAmapGCJ02: () => {
|
|
|
5
5
|
toGcj02Points: (points: Point[]) => Promise<Point[]>;
|
|
6
6
|
toLocalGcj02: (point: Point) => Point;
|
|
7
7
|
toLocalGcj02Points: (points: Point[]) => Point[];
|
|
8
|
+
toLocalWgs84: (point: Point) => Point;
|
|
8
9
|
};
|
|
9
10
|
export declare const useGmapGCJ02: () => {
|
|
10
11
|
toCoordinateType: (p: Point) => CoordinateType;
|
|
@@ -12,6 +13,7 @@ export declare const useGmapGCJ02: () => {
|
|
|
12
13
|
toGcj02Points: (points: Point[]) => Promise<Point[]>;
|
|
13
14
|
toLocalGcj02: (point: Point) => Point;
|
|
14
15
|
toLocalGcj02Points: (points: Point[]) => Point[];
|
|
16
|
+
toLocalWgs84: (point: Point) => Point;
|
|
15
17
|
};
|
|
16
18
|
export declare const useMapGCJ02: () => {
|
|
17
19
|
toCoordinateType: (p: Point) => CoordinateType;
|
|
@@ -19,4 +21,5 @@ export declare const useMapGCJ02: () => {
|
|
|
19
21
|
toGcj02Points: (points: Point[]) => Promise<Point[]>;
|
|
20
22
|
toLocalGcj02: (point: Point) => Point;
|
|
21
23
|
toLocalGcj02Points: (points: Point[]) => Point[];
|
|
24
|
+
toLocalWgs84: (point: Point) => Point;
|
|
22
25
|
};
|