@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
|
@@ -1,516 +1,6 @@
|
|
|
1
|
+
import { e as exported } from "../chunks/gcoord.esm-bundler.3f2f1369.js";
|
|
1
2
|
import { inChina, inHongkong, inMacau } from "./useMapInChina.js";
|
|
2
3
|
import { useMapSupplier } from "./useMapSupplier.js";
|
|
3
|
-
/**
|
|
4
|
-
* @preserve
|
|
5
|
-
* gcoord 1.0.5, geographic coordinate library
|
|
6
|
-
* Copyright (c) 2023 Jiulong Hu <me@hujiulong.com>
|
|
7
|
-
*/
|
|
8
|
-
const { sin: sin$1, cos: cos$1, sqrt: sqrt$1, abs: abs$1, PI: PI$1 } = Math;
|
|
9
|
-
const a = 6378245;
|
|
10
|
-
const ee = 0.006693421622965823;
|
|
11
|
-
function isInChinaBbox(lon, lat) {
|
|
12
|
-
return lon >= 72.004 && lon <= 137.8347 && lat >= 0.8293 && lat <= 55.8271;
|
|
13
|
-
}
|
|
14
|
-
function transformLat(x, y) {
|
|
15
|
-
let ret = -100 + 2 * x + 3 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt$1(abs$1(x));
|
|
16
|
-
ret += (20 * sin$1(6 * x * PI$1) + 20 * sin$1(2 * x * PI$1)) * 2 / 3;
|
|
17
|
-
ret += (20 * sin$1(y * PI$1) + 40 * sin$1(y / 3 * PI$1)) * 2 / 3;
|
|
18
|
-
ret += (160 * sin$1(y / 12 * PI$1) + 320 * sin$1(y * PI$1 / 30)) * 2 / 3;
|
|
19
|
-
return ret;
|
|
20
|
-
}
|
|
21
|
-
function transformLon(x, y) {
|
|
22
|
-
let ret = 300 + x + 2 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt$1(abs$1(x));
|
|
23
|
-
ret += (20 * sin$1(6 * x * PI$1) + 20 * sin$1(2 * x * PI$1)) * 2 / 3;
|
|
24
|
-
ret += (20 * sin$1(x * PI$1) + 40 * sin$1(x / 3 * PI$1)) * 2 / 3;
|
|
25
|
-
ret += (150 * sin$1(x / 12 * PI$1) + 300 * sin$1(x / 30 * PI$1)) * 2 / 3;
|
|
26
|
-
return ret;
|
|
27
|
-
}
|
|
28
|
-
function delta(lon, lat) {
|
|
29
|
-
let dLon = transformLon(lon - 105, lat - 35);
|
|
30
|
-
let dLat = transformLat(lon - 105, lat - 35);
|
|
31
|
-
const radLat = lat / 180 * PI$1;
|
|
32
|
-
let magic = sin$1(radLat);
|
|
33
|
-
magic = 1 - ee * magic * magic;
|
|
34
|
-
const sqrtMagic = sqrt$1(magic);
|
|
35
|
-
dLon = dLon * 180 / (a / sqrtMagic * cos$1(radLat) * PI$1);
|
|
36
|
-
dLat = dLat * 180 / (a * (1 - ee) / (magic * sqrtMagic) * PI$1);
|
|
37
|
-
return [dLon, dLat];
|
|
38
|
-
}
|
|
39
|
-
function WGS84ToGCJ02(coord) {
|
|
40
|
-
const [lon, lat] = coord;
|
|
41
|
-
if (!isInChinaBbox(lon, lat))
|
|
42
|
-
return [lon, lat];
|
|
43
|
-
const d = delta(lon, lat);
|
|
44
|
-
return [lon + d[0], lat + d[1]];
|
|
45
|
-
}
|
|
46
|
-
function GCJ02ToWGS84(coord) {
|
|
47
|
-
const [lon, lat] = coord;
|
|
48
|
-
if (!isInChinaBbox(lon, lat))
|
|
49
|
-
return [lon, lat];
|
|
50
|
-
let [wgsLon, wgsLat] = [lon, lat];
|
|
51
|
-
let tempPoint = WGS84ToGCJ02([wgsLon, wgsLat]);
|
|
52
|
-
let dx = tempPoint[0] - lon;
|
|
53
|
-
let dy = tempPoint[1] - lat;
|
|
54
|
-
while (abs$1(dx) > 1e-6 || abs$1(dy) > 1e-6) {
|
|
55
|
-
wgsLon -= dx;
|
|
56
|
-
wgsLat -= dy;
|
|
57
|
-
tempPoint = WGS84ToGCJ02([wgsLon, wgsLat]);
|
|
58
|
-
dx = tempPoint[0] - lon;
|
|
59
|
-
dy = tempPoint[1] - lat;
|
|
60
|
-
}
|
|
61
|
-
return [wgsLon, wgsLat];
|
|
62
|
-
}
|
|
63
|
-
const { sin, cos, atan2, sqrt, PI } = Math;
|
|
64
|
-
const baiduFactor = PI * 3e3 / 180;
|
|
65
|
-
function BD09ToGCJ02(coord) {
|
|
66
|
-
const [lon, lat] = coord;
|
|
67
|
-
const x = lon - 65e-4;
|
|
68
|
-
const y = lat - 6e-3;
|
|
69
|
-
const z = sqrt(x * x + y * y) - 2e-5 * sin(y * baiduFactor);
|
|
70
|
-
const theta = atan2(y, x) - 3e-6 * cos(x * baiduFactor);
|
|
71
|
-
const newLon = z * cos(theta);
|
|
72
|
-
const newLat = z * sin(theta);
|
|
73
|
-
return [newLon, newLat];
|
|
74
|
-
}
|
|
75
|
-
function GCJ02ToBD09(coord) {
|
|
76
|
-
const [lon, lat] = coord;
|
|
77
|
-
const x = lon;
|
|
78
|
-
const y = lat;
|
|
79
|
-
const z = sqrt(x * x + y * y) + 2e-5 * sin(y * baiduFactor);
|
|
80
|
-
const theta = atan2(y, x) + 3e-6 * cos(x * baiduFactor);
|
|
81
|
-
const newLon = z * cos(theta) + 65e-4;
|
|
82
|
-
const newLat = z * sin(theta) + 6e-3;
|
|
83
|
-
return [newLon, newLat];
|
|
84
|
-
}
|
|
85
|
-
const R2D = 180 / Math.PI;
|
|
86
|
-
const D2R = Math.PI / 180;
|
|
87
|
-
const A = 6378137;
|
|
88
|
-
const MAXEXTENT = 20037508342789244e-9;
|
|
89
|
-
function ESPG3857ToWGS84(xy) {
|
|
90
|
-
return [
|
|
91
|
-
xy[0] * R2D / A,
|
|
92
|
-
(Math.PI * 0.5 - 2 * Math.atan(Math.exp(-xy[1] / A))) * R2D
|
|
93
|
-
];
|
|
94
|
-
}
|
|
95
|
-
function WGS84ToEPSG3857(lonLat) {
|
|
96
|
-
const adjusted = Math.abs(lonLat[0]) <= 180 ? lonLat[0] : lonLat[0] - (lonLat[0] < 0 ? -1 : 1) * 360;
|
|
97
|
-
const xy = [
|
|
98
|
-
A * adjusted * D2R,
|
|
99
|
-
A * Math.log(Math.tan(Math.PI * 0.25 + 0.5 * lonLat[1] * D2R))
|
|
100
|
-
];
|
|
101
|
-
if (xy[0] > MAXEXTENT)
|
|
102
|
-
xy[0] = MAXEXTENT;
|
|
103
|
-
if (xy[0] < -MAXEXTENT)
|
|
104
|
-
xy[0] = -MAXEXTENT;
|
|
105
|
-
if (xy[1] > MAXEXTENT)
|
|
106
|
-
xy[1] = MAXEXTENT;
|
|
107
|
-
if (xy[1] < -MAXEXTENT)
|
|
108
|
-
xy[1] = -MAXEXTENT;
|
|
109
|
-
return xy;
|
|
110
|
-
}
|
|
111
|
-
const { abs } = Math;
|
|
112
|
-
const MCBAND = [1289059486e-2, 836237787e-2, 5591021, 348198983e-2, 167804312e-2, 0];
|
|
113
|
-
const LLBAND = [75, 60, 45, 30, 15, 0];
|
|
114
|
-
const MC2LL = [
|
|
115
|
-
[
|
|
116
|
-
1410526172116255e-23,
|
|
117
|
-
898305509648872e-20,
|
|
118
|
-
-1.9939833816331,
|
|
119
|
-
200.9824383106796,
|
|
120
|
-
-187.2403703815547,
|
|
121
|
-
91.6087516669843,
|
|
122
|
-
-23.38765649603339,
|
|
123
|
-
2.57121317296198,
|
|
124
|
-
-0.03801003308653,
|
|
125
|
-
173379812e-1
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
-7435856389565537e-24,
|
|
129
|
-
8983055097726239e-21,
|
|
130
|
-
-0.78625201886289,
|
|
131
|
-
96.32687599759846,
|
|
132
|
-
-1.85204757529826,
|
|
133
|
-
-59.36935905485877,
|
|
134
|
-
47.40033549296737,
|
|
135
|
-
-16.50741931063887,
|
|
136
|
-
2.28786674699375,
|
|
137
|
-
1026014486e-2
|
|
138
|
-
],
|
|
139
|
-
[
|
|
140
|
-
-3030883460898826e-23,
|
|
141
|
-
898305509983578e-20,
|
|
142
|
-
0.30071316287616,
|
|
143
|
-
59.74293618442277,
|
|
144
|
-
7.357984074871,
|
|
145
|
-
-25.38371002664745,
|
|
146
|
-
13.45380521110908,
|
|
147
|
-
-3.29883767235584,
|
|
148
|
-
0.32710905363475,
|
|
149
|
-
685681737e-2
|
|
150
|
-
],
|
|
151
|
-
[
|
|
152
|
-
-1981981304930552e-23,
|
|
153
|
-
8983055099779535e-21,
|
|
154
|
-
0.03278182852591,
|
|
155
|
-
40.31678527705744,
|
|
156
|
-
0.65659298677277,
|
|
157
|
-
-4.44255534477492,
|
|
158
|
-
0.85341911805263,
|
|
159
|
-
0.12923347998204,
|
|
160
|
-
-0.04625736007561,
|
|
161
|
-
448277706e-2
|
|
162
|
-
],
|
|
163
|
-
[
|
|
164
|
-
309191371068437e-23,
|
|
165
|
-
8983055096812155e-21,
|
|
166
|
-
6995724062e-14,
|
|
167
|
-
23.10934304144901,
|
|
168
|
-
-23663490511e-14,
|
|
169
|
-
-0.6321817810242,
|
|
170
|
-
-0.00663494467273,
|
|
171
|
-
0.03430082397953,
|
|
172
|
-
-0.00466043876332,
|
|
173
|
-
25551644e-1
|
|
174
|
-
],
|
|
175
|
-
[
|
|
176
|
-
2890871144776878e-24,
|
|
177
|
-
8983055095805407e-21,
|
|
178
|
-
-3068298e-14,
|
|
179
|
-
7.47137025468032,
|
|
180
|
-
-353937994e-14,
|
|
181
|
-
-0.02145144861037,
|
|
182
|
-
-1234426596e-14,
|
|
183
|
-
10322952773e-14,
|
|
184
|
-
-323890364e-14,
|
|
185
|
-
826088.5
|
|
186
|
-
]
|
|
187
|
-
];
|
|
188
|
-
const LL2MC = [
|
|
189
|
-
[
|
|
190
|
-
-0.0015702102444,
|
|
191
|
-
111320.7020616939,
|
|
192
|
-
1704480524535203,
|
|
193
|
-
-10338987376042340,
|
|
194
|
-
26112667856603880,
|
|
195
|
-
-35149669176653700,
|
|
196
|
-
26595700718403920,
|
|
197
|
-
-10725012454188240,
|
|
198
|
-
1800819912950474,
|
|
199
|
-
82.5
|
|
200
|
-
],
|
|
201
|
-
[
|
|
202
|
-
8277824516172526e-19,
|
|
203
|
-
111320.7020463578,
|
|
204
|
-
6477955746671607e-7,
|
|
205
|
-
-4082003173641316e-6,
|
|
206
|
-
1077490566351142e-5,
|
|
207
|
-
-1517187553151559e-5,
|
|
208
|
-
1205306533862167e-5,
|
|
209
|
-
-5124939663577472e-6,
|
|
210
|
-
9133119359512032e-7,
|
|
211
|
-
67.5
|
|
212
|
-
],
|
|
213
|
-
[
|
|
214
|
-
0.00337398766765,
|
|
215
|
-
111320.7020202162,
|
|
216
|
-
4481351045890365e-9,
|
|
217
|
-
-2339375119931662e-8,
|
|
218
|
-
7968221547186455e-8,
|
|
219
|
-
-1159649932797253e-7,
|
|
220
|
-
9723671115602145e-8,
|
|
221
|
-
-4366194633752821e-8,
|
|
222
|
-
8477230501135234e-9,
|
|
223
|
-
52.5
|
|
224
|
-
],
|
|
225
|
-
[
|
|
226
|
-
0.00220636496208,
|
|
227
|
-
111320.7020209128,
|
|
228
|
-
51751.86112841131,
|
|
229
|
-
3796837749470245e-9,
|
|
230
|
-
992013.7397791013,
|
|
231
|
-
-122195221711287e-8,
|
|
232
|
-
1340652697009075e-9,
|
|
233
|
-
-620943.6990984312,
|
|
234
|
-
144416.9293806241,
|
|
235
|
-
37.5
|
|
236
|
-
],
|
|
237
|
-
[
|
|
238
|
-
-3441963504368392e-19,
|
|
239
|
-
111320.7020576856,
|
|
240
|
-
278.2353980772752,
|
|
241
|
-
2485758690035394e-9,
|
|
242
|
-
6070.750963243378,
|
|
243
|
-
54821.18345352118,
|
|
244
|
-
9540.606633304236,
|
|
245
|
-
-2710.55326746645,
|
|
246
|
-
1405.483844121726,
|
|
247
|
-
22.5
|
|
248
|
-
],
|
|
249
|
-
[
|
|
250
|
-
-3218135878613132e-19,
|
|
251
|
-
111320.7020701615,
|
|
252
|
-
0.00369383431289,
|
|
253
|
-
823725.6402795718,
|
|
254
|
-
0.46104986909093,
|
|
255
|
-
2351.343141331292,
|
|
256
|
-
1.58060784298199,
|
|
257
|
-
8.77738589078284,
|
|
258
|
-
0.37238884252424,
|
|
259
|
-
7.45
|
|
260
|
-
]
|
|
261
|
-
];
|
|
262
|
-
function transform$1(x, y, factors) {
|
|
263
|
-
const cc = abs(y) / factors[9];
|
|
264
|
-
let xt = factors[0] + factors[1] * abs(x);
|
|
265
|
-
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);
|
|
266
|
-
xt *= x < 0 ? -1 : 1;
|
|
267
|
-
yt *= y < 0 ? -1 : 1;
|
|
268
|
-
return [xt, yt];
|
|
269
|
-
}
|
|
270
|
-
function BD09toBD09MC(coord) {
|
|
271
|
-
const [lng, lat] = coord;
|
|
272
|
-
let factors = [];
|
|
273
|
-
for (let i = 0; i < LLBAND.length; i++) {
|
|
274
|
-
if (abs(lat) > LLBAND[i]) {
|
|
275
|
-
factors = LL2MC[i];
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return transform$1(lng, lat, factors);
|
|
280
|
-
}
|
|
281
|
-
function BD09MCtoBD09(coord) {
|
|
282
|
-
const [x, y] = coord;
|
|
283
|
-
let factors = [];
|
|
284
|
-
for (let i = 0; i < MCBAND.length; i++) {
|
|
285
|
-
if (y >= MCBAND[i]) {
|
|
286
|
-
factors = MC2LL[i];
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return transform$1(x, y, factors);
|
|
291
|
-
}
|
|
292
|
-
function assert(condition, msg) {
|
|
293
|
-
if (!condition)
|
|
294
|
-
throw new Error(msg);
|
|
295
|
-
}
|
|
296
|
-
function isArray(input) {
|
|
297
|
-
return !!input && Object.prototype.toString.call(input) === "[object Array]";
|
|
298
|
-
}
|
|
299
|
-
function isNumber(input) {
|
|
300
|
-
return !isNaN(Number(input)) && input !== null && !isArray(input);
|
|
301
|
-
}
|
|
302
|
-
function compose(...funcs) {
|
|
303
|
-
const start = funcs.length - 1;
|
|
304
|
-
return function(...args) {
|
|
305
|
-
let i = start;
|
|
306
|
-
let result = funcs[start].apply(null, args);
|
|
307
|
-
while (i--)
|
|
308
|
-
result = funcs[i].call(null, result);
|
|
309
|
-
return result;
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
function coordEach(geojson, callback, excludeWrapCoord = false) {
|
|
313
|
-
if (geojson === null)
|
|
314
|
-
return;
|
|
315
|
-
let j;
|
|
316
|
-
let k;
|
|
317
|
-
let l;
|
|
318
|
-
let geometry;
|
|
319
|
-
let coords;
|
|
320
|
-
let stopG;
|
|
321
|
-
let wrapShrink = 0;
|
|
322
|
-
let coordIndex = 0;
|
|
323
|
-
let geometryMaybeCollection;
|
|
324
|
-
let isGeometryCollection;
|
|
325
|
-
const { type } = geojson;
|
|
326
|
-
const isFeatureCollection = type === "FeatureCollection";
|
|
327
|
-
const isFeature = type === "Feature";
|
|
328
|
-
const stop = isFeatureCollection ? geojson.features.length : 1;
|
|
329
|
-
for (let featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
330
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
331
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
332
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
333
|
-
for (let geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
334
|
-
let multiFeatureIndex = 0;
|
|
335
|
-
let geometryIndex = 0;
|
|
336
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
337
|
-
if (geometry === null)
|
|
338
|
-
continue;
|
|
339
|
-
const geomType = geometry.type;
|
|
340
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
341
|
-
switch (geomType) {
|
|
342
|
-
case null:
|
|
343
|
-
break;
|
|
344
|
-
case "Point":
|
|
345
|
-
coords = geometry.coordinates;
|
|
346
|
-
if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
347
|
-
return false;
|
|
348
|
-
coordIndex++;
|
|
349
|
-
multiFeatureIndex++;
|
|
350
|
-
break;
|
|
351
|
-
case "LineString":
|
|
352
|
-
case "MultiPoint":
|
|
353
|
-
coords = geometry.coordinates;
|
|
354
|
-
for (j = 0; j < coords.length; j++) {
|
|
355
|
-
if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
356
|
-
return false;
|
|
357
|
-
coordIndex++;
|
|
358
|
-
if (geomType === "MultiPoint")
|
|
359
|
-
multiFeatureIndex++;
|
|
360
|
-
}
|
|
361
|
-
if (geomType === "LineString")
|
|
362
|
-
multiFeatureIndex++;
|
|
363
|
-
break;
|
|
364
|
-
case "Polygon":
|
|
365
|
-
case "MultiLineString":
|
|
366
|
-
coords = geometry.coordinates;
|
|
367
|
-
for (j = 0; j < coords.length; j++) {
|
|
368
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
369
|
-
if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
370
|
-
return false;
|
|
371
|
-
coordIndex++;
|
|
372
|
-
}
|
|
373
|
-
if (geomType === "MultiLineString")
|
|
374
|
-
multiFeatureIndex++;
|
|
375
|
-
if (geomType === "Polygon")
|
|
376
|
-
geometryIndex++;
|
|
377
|
-
}
|
|
378
|
-
if (geomType === "Polygon")
|
|
379
|
-
multiFeatureIndex++;
|
|
380
|
-
break;
|
|
381
|
-
case "MultiPolygon":
|
|
382
|
-
coords = geometry.coordinates;
|
|
383
|
-
for (j = 0; j < coords.length; j++) {
|
|
384
|
-
geometryIndex = 0;
|
|
385
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
386
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
387
|
-
if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
388
|
-
return false;
|
|
389
|
-
coordIndex++;
|
|
390
|
-
}
|
|
391
|
-
geometryIndex++;
|
|
392
|
-
}
|
|
393
|
-
multiFeatureIndex++;
|
|
394
|
-
}
|
|
395
|
-
break;
|
|
396
|
-
case "GeometryCollection":
|
|
397
|
-
for (j = 0; j < geometry.geometries.length; j++) {
|
|
398
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
399
|
-
return false;
|
|
400
|
-
}
|
|
401
|
-
break;
|
|
402
|
-
default:
|
|
403
|
-
throw new Error("Unknown Geometry Type");
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
var CRSTypes;
|
|
409
|
-
(function(CRSTypes2) {
|
|
410
|
-
CRSTypes2["WGS84"] = "WGS84";
|
|
411
|
-
CRSTypes2["WGS1984"] = "WGS84";
|
|
412
|
-
CRSTypes2["EPSG4326"] = "WGS84";
|
|
413
|
-
CRSTypes2["GCJ02"] = "GCJ02";
|
|
414
|
-
CRSTypes2["AMap"] = "GCJ02";
|
|
415
|
-
CRSTypes2["BD09"] = "BD09";
|
|
416
|
-
CRSTypes2["BD09LL"] = "BD09";
|
|
417
|
-
CRSTypes2["Baidu"] = "BD09";
|
|
418
|
-
CRSTypes2["BMap"] = "BD09";
|
|
419
|
-
CRSTypes2["BD09MC"] = "BD09MC";
|
|
420
|
-
CRSTypes2["BD09Meter"] = "BD09MC";
|
|
421
|
-
CRSTypes2["EPSG3857"] = "EPSG3857";
|
|
422
|
-
CRSTypes2["EPSG900913"] = "EPSG3857";
|
|
423
|
-
CRSTypes2["EPSG102100"] = "EPSG3857";
|
|
424
|
-
CRSTypes2["WebMercator"] = "EPSG3857";
|
|
425
|
-
CRSTypes2["WM"] = "EPSG3857";
|
|
426
|
-
})(CRSTypes || (CRSTypes = {}));
|
|
427
|
-
const WGS84 = {
|
|
428
|
-
to: {
|
|
429
|
-
[CRSTypes.GCJ02]: WGS84ToGCJ02,
|
|
430
|
-
[CRSTypes.BD09]: compose(GCJ02ToBD09, WGS84ToGCJ02),
|
|
431
|
-
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09, WGS84ToGCJ02),
|
|
432
|
-
[CRSTypes.EPSG3857]: WGS84ToEPSG3857
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
const GCJ02 = {
|
|
436
|
-
to: {
|
|
437
|
-
[CRSTypes.WGS84]: GCJ02ToWGS84,
|
|
438
|
-
[CRSTypes.BD09]: GCJ02ToBD09,
|
|
439
|
-
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09),
|
|
440
|
-
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84)
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
const BD09 = {
|
|
444
|
-
to: {
|
|
445
|
-
[CRSTypes.WGS84]: compose(GCJ02ToWGS84, BD09ToGCJ02),
|
|
446
|
-
[CRSTypes.GCJ02]: BD09ToGCJ02,
|
|
447
|
-
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84, BD09ToGCJ02),
|
|
448
|
-
[CRSTypes.BD09MC]: BD09toBD09MC
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
|
-
const EPSG3857 = {
|
|
452
|
-
to: {
|
|
453
|
-
[CRSTypes.WGS84]: ESPG3857ToWGS84,
|
|
454
|
-
[CRSTypes.GCJ02]: compose(WGS84ToGCJ02, ESPG3857ToWGS84),
|
|
455
|
-
[CRSTypes.BD09]: compose(GCJ02ToBD09, WGS84ToGCJ02, ESPG3857ToWGS84),
|
|
456
|
-
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09, WGS84ToGCJ02, ESPG3857ToWGS84)
|
|
457
|
-
}
|
|
458
|
-
};
|
|
459
|
-
const BD09MC = {
|
|
460
|
-
to: {
|
|
461
|
-
[CRSTypes.WGS84]: compose(GCJ02ToWGS84, BD09ToGCJ02, BD09MCtoBD09),
|
|
462
|
-
[CRSTypes.GCJ02]: compose(BD09ToGCJ02, BD09MCtoBD09),
|
|
463
|
-
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84, BD09ToGCJ02, BD09MCtoBD09),
|
|
464
|
-
[CRSTypes.BD09]: BD09MCtoBD09
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
const crsMap = {
|
|
468
|
-
WGS84,
|
|
469
|
-
GCJ02,
|
|
470
|
-
BD09,
|
|
471
|
-
EPSG3857,
|
|
472
|
-
BD09MC
|
|
473
|
-
};
|
|
474
|
-
var crsMap$1 = crsMap;
|
|
475
|
-
function transform(input, crsFrom, crsTo) {
|
|
476
|
-
assert(!!input, "The args[0] input coordinate is required");
|
|
477
|
-
assert(!!crsFrom, "The args[1] original coordinate system is required");
|
|
478
|
-
assert(!!crsTo, "The args[2] target coordinate system is required");
|
|
479
|
-
if (crsFrom === crsTo)
|
|
480
|
-
return input;
|
|
481
|
-
const from = crsMap$1[crsFrom];
|
|
482
|
-
assert(!!from, `Invalid original coordinate system: ${crsFrom}`);
|
|
483
|
-
const to = from.to[crsTo];
|
|
484
|
-
assert(!!to, `Invalid target coordinate system: ${crsTo}`);
|
|
485
|
-
const type = typeof input;
|
|
486
|
-
assert(type === "string" || type === "object", `Invalid input coordinate type: ${type}`);
|
|
487
|
-
if (type === "string") {
|
|
488
|
-
try {
|
|
489
|
-
input = JSON.parse(input);
|
|
490
|
-
} catch (e) {
|
|
491
|
-
throw new Error(`Invalid input coordinate: ${input}`);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
let isPosition = false;
|
|
495
|
-
if (isArray(input)) {
|
|
496
|
-
assert(input.length >= 2, `Invalid input coordinate: ${input}`);
|
|
497
|
-
assert(isNumber(input[0]) && isNumber(input[1]), `Invalid input coordinate: ${input}`);
|
|
498
|
-
input = input.map(Number);
|
|
499
|
-
isPosition = true;
|
|
500
|
-
}
|
|
501
|
-
const convert = to;
|
|
502
|
-
if (isPosition)
|
|
503
|
-
return convert(input);
|
|
504
|
-
coordEach(input, (coord) => {
|
|
505
|
-
[coord[0], coord[1]] = convert(coord);
|
|
506
|
-
});
|
|
507
|
-
return input;
|
|
508
|
-
}
|
|
509
|
-
const exported = Object.assign(Object.assign({}, CRSTypes), {
|
|
510
|
-
// 兼容原来gcoord.WGS84的使用方式
|
|
511
|
-
CRSTypes,
|
|
512
|
-
transform
|
|
513
|
-
});
|
|
514
4
|
const useAmapGCJ02 = () => {
|
|
515
5
|
const toCoordinateType = (p) => {
|
|
516
6
|
return inChina(p) ? "gcj02" : "wgs84";
|
|
@@ -528,13 +18,23 @@ const useAmapGCJ02 = () => {
|
|
|
528
18
|
}
|
|
529
19
|
};
|
|
530
20
|
const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
|
|
21
|
+
const toLocalWgs84 = (point) => {
|
|
22
|
+
throw new Error(`高德地图为什么要转 wgs84: ${JSON.stringify(point)}`);
|
|
23
|
+
};
|
|
531
24
|
const toGcj02Points = async (points) => {
|
|
532
25
|
return toLocalGcj02Points(points);
|
|
533
26
|
};
|
|
534
27
|
function toGcj02(point) {
|
|
535
28
|
return toGcj02Points([point]).then(([result]) => result);
|
|
536
29
|
}
|
|
537
|
-
return {
|
|
30
|
+
return {
|
|
31
|
+
toCoordinateType,
|
|
32
|
+
toGcj02,
|
|
33
|
+
toGcj02Points,
|
|
34
|
+
toLocalGcj02,
|
|
35
|
+
toLocalGcj02Points,
|
|
36
|
+
toLocalWgs84
|
|
37
|
+
};
|
|
538
38
|
};
|
|
539
39
|
const useGmapGCJ02 = () => {
|
|
540
40
|
const toCoordinateType = (p) => {
|
|
@@ -553,13 +53,32 @@ const useGmapGCJ02 = () => {
|
|
|
553
53
|
}
|
|
554
54
|
};
|
|
555
55
|
const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
|
|
56
|
+
const toLocalWgs84 = (point) => {
|
|
57
|
+
try {
|
|
58
|
+
if (inChina(point) && !inHongkong(point) && !inMacau(point))
|
|
59
|
+
return point;
|
|
60
|
+
return exported.transform(point, exported.GCJ02, exported.WGS1984);
|
|
61
|
+
} catch (err) {
|
|
62
|
+
const error = err;
|
|
63
|
+
console.error(`本地转换WGS84失败: ${error.message}
|
|
64
|
+
${error.stack}`);
|
|
65
|
+
return point;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
556
68
|
const toGcj02 = async (point) => {
|
|
557
69
|
return toLocalGcj02Points([point])[0];
|
|
558
70
|
};
|
|
559
71
|
const toGcj02Points = async (points) => {
|
|
560
72
|
return toLocalGcj02Points(points);
|
|
561
73
|
};
|
|
562
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
toCoordinateType,
|
|
76
|
+
toGcj02,
|
|
77
|
+
toGcj02Points,
|
|
78
|
+
toLocalGcj02,
|
|
79
|
+
toLocalGcj02Points,
|
|
80
|
+
toLocalWgs84
|
|
81
|
+
};
|
|
563
82
|
};
|
|
564
83
|
const useMapGCJ02 = () => {
|
|
565
84
|
const { supplier } = useMapSupplier();
|
package/dist/v2/index.d.ts
CHANGED
package/dist/v2/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./utils/alipayPolyfill.js";
|
|
2
|
+
import { isCoordinatePointEqual } from "./api/geometry.js";
|
|
2
3
|
import { AbsoluteAddressBox } from "./business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
3
4
|
import { AddressBox } from "./business-components/AddressBox/AddressBox.js";
|
|
4
5
|
import { BusinessQuotingMap } from "./business-components/BusinessQuotingMap/BusinessQuotingMap.js";
|
|
@@ -57,6 +58,7 @@ export {
|
|
|
57
58
|
WalkingLine,
|
|
58
59
|
WalkingRoute,
|
|
59
60
|
WaveCircle,
|
|
61
|
+
isCoordinatePointEqual,
|
|
60
62
|
patchMiniprogramRedirectTo,
|
|
61
63
|
useBusinessAlarm,
|
|
62
64
|
useBusinessQuotingMap,
|
package/dist/v2/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.4.
|
|
3
|
+
const pkgVersion = "2.4.1";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -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({
|