@heycar/heycars-map 0.9.20-timeout2 → 0.9.20-timeout4
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/dist/index.cjs +991 -449
- package/dist/index.js +991 -449
- package/dist/src/api/contants.d.ts +1 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof GeolocationPositionError === "undefined") {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
const name = "@heycar/heycars-map";
|
|
20
|
-
const version = "0.9.20-
|
|
20
|
+
const version = "0.9.20-timeout4";
|
|
21
21
|
const type = "module";
|
|
22
22
|
const bin = {
|
|
23
23
|
checkVersion: "./bin/checkVersion.js"
|
|
@@ -50,6 +50,7 @@ const dependencies = {
|
|
|
50
50
|
"@googlemaps/typescript-guards": "^2.0.3",
|
|
51
51
|
"@use-gesture/vanilla": "^10.2.26",
|
|
52
52
|
"fast-equals": "^3.0.3",
|
|
53
|
+
gcoord: "^1.0.5",
|
|
53
54
|
"lodash-es": "^4.17.21",
|
|
54
55
|
"vue-demi": "^0.13.11"
|
|
55
56
|
};
|
|
@@ -191,15 +192,15 @@ function arrayMap(array, iteratee) {
|
|
|
191
192
|
}
|
|
192
193
|
return result;
|
|
193
194
|
}
|
|
194
|
-
var isArray = Array.isArray;
|
|
195
|
-
const isArray$
|
|
195
|
+
var isArray$1 = Array.isArray;
|
|
196
|
+
const isArray$2 = isArray$1;
|
|
196
197
|
var INFINITY = 1 / 0;
|
|
197
198
|
var symbolProto = Symbol$2 ? Symbol$2.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
198
199
|
function baseToString(value) {
|
|
199
200
|
if (typeof value == "string") {
|
|
200
201
|
return value;
|
|
201
202
|
}
|
|
202
|
-
if (isArray$
|
|
203
|
+
if (isArray$2(value)) {
|
|
203
204
|
return arrayMap(value, baseToString) + "";
|
|
204
205
|
}
|
|
205
206
|
if (isSymbol(value)) {
|
|
@@ -1103,8 +1104,8 @@ const useMapOverlay = (props) => {
|
|
|
1103
1104
|
};
|
|
1104
1105
|
var HAS_WEAK_MAP_SUPPORT = typeof WeakMap === "function";
|
|
1105
1106
|
var keys = Object.keys;
|
|
1106
|
-
function sameValueZeroEqual(
|
|
1107
|
-
return
|
|
1107
|
+
function sameValueZeroEqual(a2, b) {
|
|
1108
|
+
return a2 === b || a2 !== a2 && b !== b;
|
|
1108
1109
|
}
|
|
1109
1110
|
function isPlainObject(value) {
|
|
1110
1111
|
return value.constructor === Object || value.constructor == null;
|
|
@@ -1155,55 +1156,55 @@ var getNewCache = function(canUseWeakMap) {
|
|
|
1155
1156
|
function createCircularEqualCreator(isEqual) {
|
|
1156
1157
|
return function createCircularEqual(comparator) {
|
|
1157
1158
|
var _comparator = isEqual || comparator;
|
|
1158
|
-
return function circularEqual(
|
|
1159
|
+
return function circularEqual(a2, b, indexOrKeyA, indexOrKeyB, parentA, parentB, cache) {
|
|
1159
1160
|
if (cache === void 0) {
|
|
1160
1161
|
cache = getNewCache();
|
|
1161
1162
|
}
|
|
1162
|
-
var isCacheableA = !!
|
|
1163
|
+
var isCacheableA = !!a2 && typeof a2 === "object";
|
|
1163
1164
|
var isCacheableB = !!b && typeof b === "object";
|
|
1164
1165
|
if (isCacheableA !== isCacheableB) {
|
|
1165
1166
|
return false;
|
|
1166
1167
|
}
|
|
1167
1168
|
if (!isCacheableA && !isCacheableB) {
|
|
1168
|
-
return _comparator(
|
|
1169
|
+
return _comparator(a2, b, cache);
|
|
1169
1170
|
}
|
|
1170
|
-
var cachedA = cache.get(
|
|
1171
|
+
var cachedA = cache.get(a2);
|
|
1171
1172
|
if (cachedA && cache.get(b)) {
|
|
1172
1173
|
return cachedA === b;
|
|
1173
1174
|
}
|
|
1174
|
-
cache.set(
|
|
1175
|
-
cache.set(b,
|
|
1176
|
-
var result = _comparator(
|
|
1177
|
-
cache.delete(
|
|
1175
|
+
cache.set(a2, b);
|
|
1176
|
+
cache.set(b, a2);
|
|
1177
|
+
var result = _comparator(a2, b, cache);
|
|
1178
|
+
cache.delete(a2);
|
|
1178
1179
|
cache.delete(b);
|
|
1179
1180
|
return result;
|
|
1180
1181
|
};
|
|
1181
1182
|
};
|
|
1182
1183
|
}
|
|
1183
|
-
function areArraysEqual(
|
|
1184
|
-
var index =
|
|
1184
|
+
function areArraysEqual(a2, b, isEqual, meta) {
|
|
1185
|
+
var index = a2.length;
|
|
1185
1186
|
if (b.length !== index) {
|
|
1186
1187
|
return false;
|
|
1187
1188
|
}
|
|
1188
1189
|
while (index-- > 0) {
|
|
1189
|
-
if (!isEqual(
|
|
1190
|
+
if (!isEqual(a2[index], b[index], index, index, a2, b, meta)) {
|
|
1190
1191
|
return false;
|
|
1191
1192
|
}
|
|
1192
1193
|
}
|
|
1193
1194
|
return true;
|
|
1194
1195
|
}
|
|
1195
|
-
function areMapsEqual(
|
|
1196
|
-
var isValueEqual =
|
|
1197
|
-
if (isValueEqual &&
|
|
1196
|
+
function areMapsEqual(a2, b, isEqual, meta) {
|
|
1197
|
+
var isValueEqual = a2.size === b.size;
|
|
1198
|
+
if (isValueEqual && a2.size) {
|
|
1198
1199
|
var matchedIndices_1 = {};
|
|
1199
1200
|
var indexA_1 = 0;
|
|
1200
|
-
|
|
1201
|
+
a2.forEach(function(aValue, aKey) {
|
|
1201
1202
|
if (isValueEqual) {
|
|
1202
1203
|
var hasMatch_1 = false;
|
|
1203
1204
|
var matchIndexB_1 = 0;
|
|
1204
1205
|
b.forEach(function(bValue, bKey) {
|
|
1205
1206
|
if (!hasMatch_1 && !matchedIndices_1[matchIndexB_1]) {
|
|
1206
|
-
hasMatch_1 = isEqual(aKey, bKey, indexA_1, matchIndexB_1,
|
|
1207
|
+
hasMatch_1 = isEqual(aKey, bKey, indexA_1, matchIndexB_1, a2, b, meta) && isEqual(aValue, bValue, aKey, bKey, a2, b, meta);
|
|
1207
1208
|
if (hasMatch_1) {
|
|
1208
1209
|
matchedIndices_1[matchIndexB_1] = true;
|
|
1209
1210
|
}
|
|
@@ -1219,8 +1220,8 @@ function areMapsEqual(a, b, isEqual, meta) {
|
|
|
1219
1220
|
}
|
|
1220
1221
|
var OWNER = "_owner";
|
|
1221
1222
|
var hasOwnProperty = Function.prototype.bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
|
|
1222
|
-
function areObjectsEqual(
|
|
1223
|
-
var keysA = keys(
|
|
1223
|
+
function areObjectsEqual(a2, b, isEqual, meta) {
|
|
1224
|
+
var keysA = keys(a2);
|
|
1224
1225
|
var index = keysA.length;
|
|
1225
1226
|
if (keys(b).length !== index) {
|
|
1226
1227
|
return false;
|
|
@@ -1230,13 +1231,13 @@ function areObjectsEqual(a, b, isEqual, meta) {
|
|
|
1230
1231
|
while (index-- > 0) {
|
|
1231
1232
|
key = keysA[index];
|
|
1232
1233
|
if (key === OWNER) {
|
|
1233
|
-
var reactElementA = isReactElement(
|
|
1234
|
+
var reactElementA = isReactElement(a2);
|
|
1234
1235
|
var reactElementB = isReactElement(b);
|
|
1235
1236
|
if ((reactElementA || reactElementB) && reactElementA !== reactElementB) {
|
|
1236
1237
|
return false;
|
|
1237
1238
|
}
|
|
1238
1239
|
}
|
|
1239
|
-
if (!hasOwnProperty(b, key) || !isEqual(
|
|
1240
|
+
if (!hasOwnProperty(b, key) || !isEqual(a2[key], b[key], key, key, a2, b, meta)) {
|
|
1240
1241
|
return false;
|
|
1241
1242
|
}
|
|
1242
1243
|
}
|
|
@@ -1245,25 +1246,25 @@ function areObjectsEqual(a, b, isEqual, meta) {
|
|
|
1245
1246
|
}
|
|
1246
1247
|
var areRegExpsEqual = function() {
|
|
1247
1248
|
if (/foo/g.flags === "g") {
|
|
1248
|
-
return function areRegExpsEqual2(
|
|
1249
|
-
return
|
|
1249
|
+
return function areRegExpsEqual2(a2, b) {
|
|
1250
|
+
return a2.source === b.source && a2.flags === b.flags;
|
|
1250
1251
|
};
|
|
1251
1252
|
}
|
|
1252
|
-
return function areRegExpsEqualFallback(
|
|
1253
|
-
return
|
|
1253
|
+
return function areRegExpsEqualFallback(a2, b) {
|
|
1254
|
+
return a2.source === b.source && a2.global === b.global && a2.ignoreCase === b.ignoreCase && a2.multiline === b.multiline && a2.unicode === b.unicode && a2.sticky === b.sticky && a2.lastIndex === b.lastIndex;
|
|
1254
1255
|
};
|
|
1255
1256
|
}();
|
|
1256
|
-
function areSetsEqual(
|
|
1257
|
-
var isValueEqual =
|
|
1258
|
-
if (isValueEqual &&
|
|
1257
|
+
function areSetsEqual(a2, b, isEqual, meta) {
|
|
1258
|
+
var isValueEqual = a2.size === b.size;
|
|
1259
|
+
if (isValueEqual && a2.size) {
|
|
1259
1260
|
var matchedIndices_2 = {};
|
|
1260
|
-
|
|
1261
|
+
a2.forEach(function(aValue, aKey) {
|
|
1261
1262
|
if (isValueEqual) {
|
|
1262
1263
|
var hasMatch_2 = false;
|
|
1263
1264
|
var matchIndex_1 = 0;
|
|
1264
1265
|
b.forEach(function(bValue, bKey) {
|
|
1265
1266
|
if (!hasMatch_2 && !matchedIndices_2[matchIndex_1]) {
|
|
1266
|
-
hasMatch_2 = isEqual(aValue, bValue, aKey, bKey,
|
|
1267
|
+
hasMatch_2 = isEqual(aValue, bValue, aKey, bKey, a2, b, meta);
|
|
1267
1268
|
if (hasMatch_2) {
|
|
1268
1269
|
matchedIndices_2[matchIndex_1] = true;
|
|
1269
1270
|
}
|
|
@@ -1282,56 +1283,56 @@ var valueOf = Object.prototype.valueOf;
|
|
|
1282
1283
|
function createComparator(createIsEqual) {
|
|
1283
1284
|
var isEqual = (
|
|
1284
1285
|
/* eslint-disable no-use-before-define */
|
|
1285
|
-
typeof createIsEqual === "function" ? createIsEqual(comparator) : function(
|
|
1286
|
-
return comparator(
|
|
1286
|
+
typeof createIsEqual === "function" ? createIsEqual(comparator) : function(a2, b, indexOrKeyA, indexOrKeyB, parentA, parentB, meta) {
|
|
1287
|
+
return comparator(a2, b, meta);
|
|
1287
1288
|
}
|
|
1288
1289
|
);
|
|
1289
|
-
function comparator(
|
|
1290
|
-
if (
|
|
1290
|
+
function comparator(a2, b, meta) {
|
|
1291
|
+
if (a2 === b) {
|
|
1291
1292
|
return true;
|
|
1292
1293
|
}
|
|
1293
|
-
if (
|
|
1294
|
-
if (isPlainObject(
|
|
1295
|
-
return areObjectsEqual(
|
|
1294
|
+
if (a2 && b && typeof a2 === "object" && typeof b === "object") {
|
|
1295
|
+
if (isPlainObject(a2) && isPlainObject(b)) {
|
|
1296
|
+
return areObjectsEqual(a2, b, isEqual, meta);
|
|
1296
1297
|
}
|
|
1297
|
-
var aShape = Array.isArray(
|
|
1298
|
+
var aShape = Array.isArray(a2);
|
|
1298
1299
|
var bShape = Array.isArray(b);
|
|
1299
1300
|
if (aShape || bShape) {
|
|
1300
|
-
return aShape === bShape && areArraysEqual(
|
|
1301
|
+
return aShape === bShape && areArraysEqual(a2, b, isEqual, meta);
|
|
1301
1302
|
}
|
|
1302
|
-
aShape =
|
|
1303
|
+
aShape = a2 instanceof Date;
|
|
1303
1304
|
bShape = b instanceof Date;
|
|
1304
1305
|
if (aShape || bShape) {
|
|
1305
|
-
return aShape === bShape && sameValueZeroEqual(
|
|
1306
|
+
return aShape === bShape && sameValueZeroEqual(a2.getTime(), b.getTime());
|
|
1306
1307
|
}
|
|
1307
|
-
aShape =
|
|
1308
|
+
aShape = a2 instanceof RegExp;
|
|
1308
1309
|
bShape = b instanceof RegExp;
|
|
1309
1310
|
if (aShape || bShape) {
|
|
1310
|
-
return aShape === bShape && areRegExpsEqual(
|
|
1311
|
+
return aShape === bShape && areRegExpsEqual(a2, b);
|
|
1311
1312
|
}
|
|
1312
|
-
if (isPromiseLike(
|
|
1313
|
-
return
|
|
1313
|
+
if (isPromiseLike(a2) || isPromiseLike(b)) {
|
|
1314
|
+
return a2 === b;
|
|
1314
1315
|
}
|
|
1315
1316
|
if (HAS_MAP_SUPPORT) {
|
|
1316
|
-
aShape =
|
|
1317
|
+
aShape = a2 instanceof Map;
|
|
1317
1318
|
bShape = b instanceof Map;
|
|
1318
1319
|
if (aShape || bShape) {
|
|
1319
|
-
return aShape === bShape && areMapsEqual(
|
|
1320
|
+
return aShape === bShape && areMapsEqual(a2, b, isEqual, meta);
|
|
1320
1321
|
}
|
|
1321
1322
|
}
|
|
1322
1323
|
if (HAS_SET_SUPPORT) {
|
|
1323
|
-
aShape =
|
|
1324
|
+
aShape = a2 instanceof Set;
|
|
1324
1325
|
bShape = b instanceof Set;
|
|
1325
1326
|
if (aShape || bShape) {
|
|
1326
|
-
return aShape === bShape && areSetsEqual(
|
|
1327
|
+
return aShape === bShape && areSetsEqual(a2, b, isEqual, meta);
|
|
1327
1328
|
}
|
|
1328
1329
|
}
|
|
1329
|
-
if (
|
|
1330
|
-
return sameValueZeroEqual(
|
|
1330
|
+
if (a2.valueOf !== valueOf || b.valueOf !== valueOf) {
|
|
1331
|
+
return sameValueZeroEqual(a2.valueOf(), b.valueOf());
|
|
1331
1332
|
}
|
|
1332
|
-
return areObjectsEqual(
|
|
1333
|
+
return areObjectsEqual(a2, b, isEqual, meta);
|
|
1333
1334
|
}
|
|
1334
|
-
return
|
|
1335
|
+
return a2 !== a2 && b !== b;
|
|
1335
1336
|
}
|
|
1336
1337
|
return comparator;
|
|
1337
1338
|
}
|
|
@@ -1440,6 +1441,7 @@ const TRACKS_MATCH_MAX_LENGTH = 3;
|
|
|
1440
1441
|
const REGEO_TIMEOUT = 5e3;
|
|
1441
1442
|
const GET_RECOMMEND_PLACE_TIMEOUT = 5e3;
|
|
1442
1443
|
const GET_DEFAULT_CENTER_PLACE_TIMEOUT = 5e3;
|
|
1444
|
+
const AMAP_TO_GCJ02_TIMEOUT = 2e3;
|
|
1443
1445
|
const IS_ENABLE_AUXILIARY_GRASP_ROAD = location.search.includes("enableAuxiliaryGraspRoad");
|
|
1444
1446
|
const AMAP_DEFAULT_MARKER_ICON_URL = "https://webapi.amap.com/theme/v1.3/markers/b/mark_bs.png";
|
|
1445
1447
|
var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
|
|
@@ -1689,7 +1691,7 @@ const toTrackPoint = (maybeTrackPoint) => {
|
|
|
1689
1691
|
return { lng, lat, angle, speed, timestamp };
|
|
1690
1692
|
};
|
|
1691
1693
|
const toTrackPoints = (maybeTrackPoints) => {
|
|
1692
|
-
if (!isArray$
|
|
1694
|
+
if (!isArray$2(maybeTrackPoints))
|
|
1693
1695
|
throwTypeError("TrackPoint[]", maybeTrackPoints);
|
|
1694
1696
|
return maybeTrackPoints.map(toTrackPoint);
|
|
1695
1697
|
};
|
|
@@ -1747,12 +1749,12 @@ const alipayMyGetLocationError2GeolocationPositionErrorCode = (code) => {
|
|
|
1747
1749
|
const geoPositionError2businessTimeout = (error, platform) => {
|
|
1748
1750
|
return platform !== BRWOSER_PLATFORM.WECHAT && platform !== BRWOSER_PLATFORM.WECHAT_MINIPROGRAM && error.code === GeolocationPositionError.TIMEOUT;
|
|
1749
1751
|
};
|
|
1750
|
-
const deepCompareEqualsForMaps = createComparator((deepEqual) => (
|
|
1751
|
-
if (isLatLngLiteral(
|
|
1752
|
-
const result = isPlaceEqual(
|
|
1752
|
+
const deepCompareEqualsForMaps = createComparator((deepEqual) => (a2, b) => {
|
|
1753
|
+
if (isLatLngLiteral(a2) && isLatLngLiteral(b)) {
|
|
1754
|
+
const result = isPlaceEqual(a2, b);
|
|
1753
1755
|
return result;
|
|
1754
1756
|
}
|
|
1755
|
-
return deepEqual(
|
|
1757
|
+
return deepEqual(a2, b);
|
|
1756
1758
|
});
|
|
1757
1759
|
function createDeepCompareMemoize() {
|
|
1758
1760
|
let prev = void 0;
|
|
@@ -2110,28 +2112,28 @@ var dist = {
|
|
|
2110
2112
|
(function(m, p) {
|
|
2111
2113
|
module2.exports = p();
|
|
2112
2114
|
})(commonjsGlobal, function() {
|
|
2113
|
-
function m(
|
|
2115
|
+
function m(a2) {
|
|
2114
2116
|
var b2 = [];
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
+
a2.AMapUI && b2.push(p(a2.AMapUI));
|
|
2118
|
+
a2.Loca && b2.push(r(a2.Loca));
|
|
2117
2119
|
return Promise.all(b2);
|
|
2118
2120
|
}
|
|
2119
|
-
function p(
|
|
2121
|
+
function p(a2) {
|
|
2120
2122
|
return new Promise(function(h2, c) {
|
|
2121
2123
|
var f = [];
|
|
2122
|
-
if (
|
|
2123
|
-
for (var e = 0; e <
|
|
2124
|
-
-1 == d.AMapUI.plugins.indexOf(
|
|
2124
|
+
if (a2.plugins)
|
|
2125
|
+
for (var e = 0; e < a2.plugins.length; e += 1)
|
|
2126
|
+
-1 == d.AMapUI.plugins.indexOf(a2.plugins[e]) && f.push(a2.plugins[e]);
|
|
2125
2127
|
if (g.AMapUI === b.failed)
|
|
2126
2128
|
c("前次请求 AMapUI 失败");
|
|
2127
2129
|
else if (g.AMapUI === b.notload) {
|
|
2128
2130
|
g.AMapUI = b.loading;
|
|
2129
|
-
d.AMapUI.version =
|
|
2131
|
+
d.AMapUI.version = a2.version || d.AMapUI.version;
|
|
2130
2132
|
e = d.AMapUI.version;
|
|
2131
2133
|
var l = document.body || document.head, k = document.createElement("script");
|
|
2132
2134
|
k.type = "text/javascript";
|
|
2133
2135
|
k.src = "https://webapi.amap.com/ui/" + e + "/main.js";
|
|
2134
|
-
k.onerror = function(
|
|
2136
|
+
k.onerror = function(a3) {
|
|
2135
2137
|
g.AMapUI = b.failed;
|
|
2136
2138
|
c("请求 AMapUI 失败");
|
|
2137
2139
|
};
|
|
@@ -2139,9 +2141,9 @@ var dist = {
|
|
|
2139
2141
|
g.AMapUI = b.loaded;
|
|
2140
2142
|
if (f.length)
|
|
2141
2143
|
window.AMapUI.loadUI(f, function() {
|
|
2142
|
-
for (var
|
|
2143
|
-
var c2 = f[
|
|
2144
|
-
window.AMapUI[c2] = arguments[
|
|
2144
|
+
for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
|
|
2145
|
+
var c2 = f[a3].split("/").slice(-1)[0];
|
|
2146
|
+
window.AMapUI[c2] = arguments[a3];
|
|
2145
2147
|
}
|
|
2146
2148
|
for (h2(); n.AMapUI.length; )
|
|
2147
2149
|
n.AMapUI.splice(0, 1)[0]();
|
|
@@ -2152,30 +2154,30 @@ var dist = {
|
|
|
2152
2154
|
};
|
|
2153
2155
|
l.appendChild(k);
|
|
2154
2156
|
} else
|
|
2155
|
-
g.AMapUI === b.loaded ?
|
|
2156
|
-
for (var
|
|
2157
|
-
var c2 = f[
|
|
2158
|
-
window.AMapUI[c2] = arguments[
|
|
2157
|
+
g.AMapUI === b.loaded ? a2.version && a2.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : f.length ? window.AMapUI.loadUI(f, function() {
|
|
2158
|
+
for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
|
|
2159
|
+
var c2 = f[a3].split("/").slice(-1)[0];
|
|
2160
|
+
window.AMapUI[c2] = arguments[a3];
|
|
2159
2161
|
}
|
|
2160
2162
|
h2();
|
|
2161
|
-
}) : h2() :
|
|
2162
|
-
|
|
2163
|
-
for (var
|
|
2164
|
-
var c2 = f[
|
|
2165
|
-
window.AMapUI[c2] = arguments[
|
|
2163
|
+
}) : h2() : a2.version && a2.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : n.AMapUI.push(function(a3) {
|
|
2164
|
+
a3 ? c(a3) : f.length ? window.AMapUI.loadUI(f, function() {
|
|
2165
|
+
for (var a4 = 0, b2 = f.length; a4 < b2; a4++) {
|
|
2166
|
+
var c2 = f[a4].split("/").slice(-1)[0];
|
|
2167
|
+
window.AMapUI[c2] = arguments[a4];
|
|
2166
2168
|
}
|
|
2167
2169
|
h2();
|
|
2168
2170
|
}) : h2();
|
|
2169
2171
|
});
|
|
2170
2172
|
});
|
|
2171
2173
|
}
|
|
2172
|
-
function r(
|
|
2174
|
+
function r(a2) {
|
|
2173
2175
|
return new Promise(function(h2, c) {
|
|
2174
2176
|
if (g.Loca === b.failed)
|
|
2175
2177
|
c("前次请求 Loca 失败");
|
|
2176
2178
|
else if (g.Loca === b.notload) {
|
|
2177
2179
|
g.Loca = b.loading;
|
|
2178
|
-
d.Loca.version =
|
|
2180
|
+
d.Loca.version = a2.version || d.Loca.version;
|
|
2179
2181
|
var f = d.Loca.version, e = d.AMap.version.startsWith("2"), l = f.startsWith("2");
|
|
2180
2182
|
if (e && !l || !e && l)
|
|
2181
2183
|
c("JSAPI 与 Loca 版本不对应!!");
|
|
@@ -2185,7 +2187,7 @@ var dist = {
|
|
|
2185
2187
|
var k = document.createElement("script");
|
|
2186
2188
|
k.type = "text/javascript";
|
|
2187
2189
|
k.src = "https://webapi.amap.com/loca?v=" + f + "&key=" + e;
|
|
2188
|
-
k.onerror = function(
|
|
2190
|
+
k.onerror = function(a3) {
|
|
2189
2191
|
g.Loca = b.failed;
|
|
2190
2192
|
c("请求 AMapUI 失败");
|
|
2191
2193
|
};
|
|
@@ -2197,81 +2199,81 @@ var dist = {
|
|
|
2197
2199
|
l.appendChild(k);
|
|
2198
2200
|
}
|
|
2199
2201
|
} else
|
|
2200
|
-
g.Loca === b.loaded ?
|
|
2201
|
-
|
|
2202
|
+
g.Loca === b.loaded ? a2.version && a2.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : h2() : a2.version && a2.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : n.Loca.push(function(a3) {
|
|
2203
|
+
a3 ? c(a3) : c();
|
|
2202
2204
|
});
|
|
2203
2205
|
});
|
|
2204
2206
|
}
|
|
2205
2207
|
if (!window)
|
|
2206
2208
|
throw Error("AMap JSAPI can only be used in Browser.");
|
|
2207
2209
|
var b;
|
|
2208
|
-
(function(
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2210
|
+
(function(a2) {
|
|
2211
|
+
a2.notload = "notload";
|
|
2212
|
+
a2.loading = "loading";
|
|
2213
|
+
a2.loaded = "loaded";
|
|
2214
|
+
a2.failed = "failed";
|
|
2213
2215
|
})(b || (b = {}));
|
|
2214
|
-
var d = { key: "", AMap: { version: "1.4.15", plugins: [] }, AMapUI: { version: "1.1", plugins: [] }, Loca: { version: "1.3.2" } }, g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload }, n = { AMap: [], AMapUI: [], Loca: [] }, q = [], t = function(
|
|
2215
|
-
"function" == typeof
|
|
2216
|
+
var d = { key: "", AMap: { version: "1.4.15", plugins: [] }, AMapUI: { version: "1.1", plugins: [] }, Loca: { version: "1.3.2" } }, g = { AMap: b.notload, AMapUI: b.notload, Loca: b.notload }, n = { AMap: [], AMapUI: [], Loca: [] }, q = [], t = function(a2) {
|
|
2217
|
+
"function" == typeof a2 && (g.AMap === b.loaded ? a2(window.AMap) : q.push(a2));
|
|
2216
2218
|
};
|
|
2217
|
-
return { load: function(
|
|
2219
|
+
return { load: function(a2) {
|
|
2218
2220
|
return new Promise(function(h2, c) {
|
|
2219
2221
|
if (g.AMap == b.failed)
|
|
2220
2222
|
c("");
|
|
2221
2223
|
else if (g.AMap == b.notload) {
|
|
2222
|
-
var f =
|
|
2224
|
+
var f = a2.key, e = a2.version, l = a2.plugins;
|
|
2223
2225
|
f ? (window.AMap && "lbs.amap.com" !== location.host && c("禁止多种API加载方式混用"), d.key = f, d.AMap.version = e || d.AMap.version, d.AMap.plugins = l || d.AMap.plugins, g.AMap = b.loading, e = document.body || document.head, window.___onAPILoaded = function(d2) {
|
|
2224
2226
|
delete window.___onAPILoaded;
|
|
2225
2227
|
if (d2)
|
|
2226
2228
|
g.AMap = b.failed, c(d2);
|
|
2227
2229
|
else
|
|
2228
|
-
for (g.AMap = b.loaded, m(
|
|
2230
|
+
for (g.AMap = b.loaded, m(a2).then(function() {
|
|
2229
2231
|
h2(window.AMap);
|
|
2230
2232
|
})["catch"](c); q.length; )
|
|
2231
2233
|
q.splice(0, 1)[0]();
|
|
2232
|
-
}, l = document.createElement("script"), l.type = "text/javascript", l.src = "https://webapi.amap.com/maps?callback=___onAPILoaded&v=" + d.AMap.version + "&key=" + f + "&plugin=" + d.AMap.plugins.join(","), l.onerror = function(
|
|
2234
|
+
}, l = document.createElement("script"), l.type = "text/javascript", l.src = "https://webapi.amap.com/maps?callback=___onAPILoaded&v=" + d.AMap.version + "&key=" + f + "&plugin=" + d.AMap.plugins.join(","), l.onerror = function(a3) {
|
|
2233
2235
|
g.AMap = b.failed;
|
|
2234
|
-
c(
|
|
2236
|
+
c(a3);
|
|
2235
2237
|
}, e.appendChild(l)) : c("请填写key");
|
|
2236
2238
|
} else if (g.AMap == b.loaded)
|
|
2237
|
-
if (
|
|
2239
|
+
if (a2.key && a2.key !== d.key)
|
|
2238
2240
|
c("多个不一致的 key");
|
|
2239
|
-
else if (
|
|
2241
|
+
else if (a2.version && a2.version !== d.AMap.version)
|
|
2240
2242
|
c("不允许多个版本 JSAPI 混用");
|
|
2241
2243
|
else {
|
|
2242
2244
|
f = [];
|
|
2243
|
-
if (
|
|
2244
|
-
for (e = 0; e <
|
|
2245
|
-
-1 == d.AMap.plugins.indexOf(
|
|
2245
|
+
if (a2.plugins)
|
|
2246
|
+
for (e = 0; e < a2.plugins.length; e += 1)
|
|
2247
|
+
-1 == d.AMap.plugins.indexOf(a2.plugins[e]) && f.push(a2.plugins[e]);
|
|
2246
2248
|
if (f.length)
|
|
2247
2249
|
window.AMap.plugin(f, function() {
|
|
2248
|
-
m(
|
|
2250
|
+
m(a2).then(function() {
|
|
2249
2251
|
h2(window.AMap);
|
|
2250
2252
|
})["catch"](c);
|
|
2251
2253
|
});
|
|
2252
2254
|
else
|
|
2253
|
-
m(
|
|
2255
|
+
m(a2).then(function() {
|
|
2254
2256
|
h2(window.AMap);
|
|
2255
2257
|
})["catch"](c);
|
|
2256
2258
|
}
|
|
2257
|
-
else if (
|
|
2259
|
+
else if (a2.key && a2.key !== d.key)
|
|
2258
2260
|
c("多个不一致的 key");
|
|
2259
|
-
else if (
|
|
2261
|
+
else if (a2.version && a2.version !== d.AMap.version)
|
|
2260
2262
|
c("不允许多个版本 JSAPI 混用");
|
|
2261
2263
|
else {
|
|
2262
2264
|
var k = [];
|
|
2263
|
-
if (
|
|
2264
|
-
for (e = 0; e <
|
|
2265
|
-
-1 == d.AMap.plugins.indexOf(
|
|
2265
|
+
if (a2.plugins)
|
|
2266
|
+
for (e = 0; e < a2.plugins.length; e += 1)
|
|
2267
|
+
-1 == d.AMap.plugins.indexOf(a2.plugins[e]) && k.push(a2.plugins[e]);
|
|
2266
2268
|
t(function() {
|
|
2267
2269
|
if (k.length)
|
|
2268
2270
|
window.AMap.plugin(k, function() {
|
|
2269
|
-
m(
|
|
2271
|
+
m(a2).then(function() {
|
|
2270
2272
|
h2(window.AMap);
|
|
2271
2273
|
})["catch"](c);
|
|
2272
2274
|
});
|
|
2273
2275
|
else
|
|
2274
|
-
m(
|
|
2276
|
+
m(a2).then(function() {
|
|
2275
2277
|
h2(window.AMap);
|
|
2276
2278
|
})["catch"](c);
|
|
2277
2279
|
});
|
|
@@ -2291,29 +2293,29 @@ var dist = {
|
|
|
2291
2293
|
} };
|
|
2292
2294
|
});
|
|
2293
2295
|
})(dist);
|
|
2294
|
-
var fastDeepEqual = function equal(
|
|
2295
|
-
if (
|
|
2296
|
+
var fastDeepEqual = function equal(a2, b) {
|
|
2297
|
+
if (a2 === b)
|
|
2296
2298
|
return true;
|
|
2297
|
-
if (
|
|
2298
|
-
if (
|
|
2299
|
+
if (a2 && b && typeof a2 == "object" && typeof b == "object") {
|
|
2300
|
+
if (a2.constructor !== b.constructor)
|
|
2299
2301
|
return false;
|
|
2300
2302
|
var length, i, keys2;
|
|
2301
|
-
if (Array.isArray(
|
|
2302
|
-
length =
|
|
2303
|
+
if (Array.isArray(a2)) {
|
|
2304
|
+
length = a2.length;
|
|
2303
2305
|
if (length != b.length)
|
|
2304
2306
|
return false;
|
|
2305
2307
|
for (i = length; i-- !== 0; )
|
|
2306
|
-
if (!equal(
|
|
2308
|
+
if (!equal(a2[i], b[i]))
|
|
2307
2309
|
return false;
|
|
2308
2310
|
return true;
|
|
2309
2311
|
}
|
|
2310
|
-
if (
|
|
2311
|
-
return
|
|
2312
|
-
if (
|
|
2313
|
-
return
|
|
2314
|
-
if (
|
|
2315
|
-
return
|
|
2316
|
-
keys2 = Object.keys(
|
|
2312
|
+
if (a2.constructor === RegExp)
|
|
2313
|
+
return a2.source === b.source && a2.flags === b.flags;
|
|
2314
|
+
if (a2.valueOf !== Object.prototype.valueOf)
|
|
2315
|
+
return a2.valueOf() === b.valueOf();
|
|
2316
|
+
if (a2.toString !== Object.prototype.toString)
|
|
2317
|
+
return a2.toString() === b.toString();
|
|
2318
|
+
keys2 = Object.keys(a2);
|
|
2317
2319
|
length = keys2.length;
|
|
2318
2320
|
if (length !== Object.keys(b).length)
|
|
2319
2321
|
return false;
|
|
@@ -2322,12 +2324,12 @@ var fastDeepEqual = function equal(a, b) {
|
|
|
2322
2324
|
return false;
|
|
2323
2325
|
for (i = length; i-- !== 0; ) {
|
|
2324
2326
|
var key = keys2[i];
|
|
2325
|
-
if (!equal(
|
|
2327
|
+
if (!equal(a2[key], b[key]))
|
|
2326
2328
|
return false;
|
|
2327
2329
|
}
|
|
2328
2330
|
return true;
|
|
2329
2331
|
}
|
|
2330
|
-
return
|
|
2332
|
+
return a2 !== a2 && b !== b;
|
|
2331
2333
|
};
|
|
2332
2334
|
const DEFAULT_ID = "__googleMapsScriptId";
|
|
2333
2335
|
var LoaderStatus;
|
|
@@ -4760,15 +4762,15 @@ function compatibleWathPosition(onSuccess, onError, option) {
|
|
|
4760
4762
|
const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
|
|
4761
4763
|
return () => navigator.geolocation.clearWatch(watchId);
|
|
4762
4764
|
}
|
|
4763
|
-
function compatibleGeoPositionTransform(position,
|
|
4765
|
+
function compatibleGeoPositionTransform(position, transform2) {
|
|
4764
4766
|
const os = detectOSPlatform();
|
|
4765
4767
|
const platform = detectBrowserPlatform();
|
|
4766
4768
|
const wallet = detectAlipayWallet();
|
|
4767
4769
|
if ((wallet === ALIPAY_WALLET.TNGD || wallet === ALIPAY_WALLET.TMN) && os === OS_PLATFORM.ANDROID)
|
|
4768
|
-
return
|
|
4770
|
+
return transform2(position);
|
|
4769
4771
|
if (platform === BRWOSER_PLATFORM.ALIPAY || platform === BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM)
|
|
4770
4772
|
return position;
|
|
4771
|
-
return
|
|
4773
|
+
return transform2(position);
|
|
4772
4774
|
}
|
|
4773
4775
|
class SingleGeoWatch {
|
|
4774
4776
|
constructor(option) {
|
|
@@ -4809,318 +4811,517 @@ class SingleGeoWatch {
|
|
|
4809
4811
|
);
|
|
4810
4812
|
}
|
|
4811
4813
|
}
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4814
|
+
/**
|
|
4815
|
+
* @preserve
|
|
4816
|
+
* gcoord 1.0.5, geographic coordinate library
|
|
4817
|
+
* Copyright (c) 2023 Jiulong Hu <me@hujiulong.com>
|
|
4818
|
+
*/
|
|
4819
|
+
const { sin: sin$1, cos: cos$1, sqrt: sqrt$1, abs: abs$1, PI: PI$1 } = Math;
|
|
4820
|
+
const a = 6378245;
|
|
4821
|
+
const ee = 0.006693421622965823;
|
|
4822
|
+
function isInChinaBbox(lon, lat) {
|
|
4823
|
+
return lon >= 72.004 && lon <= 137.8347 && lat >= 0.8293 && lat <= 55.8271;
|
|
4824
|
+
}
|
|
4825
|
+
function transformLat(x, y) {
|
|
4826
|
+
let ret = -100 + 2 * x + 3 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * sqrt$1(abs$1(x));
|
|
4827
|
+
ret += (20 * sin$1(6 * x * PI$1) + 20 * sin$1(2 * x * PI$1)) * 2 / 3;
|
|
4828
|
+
ret += (20 * sin$1(y * PI$1) + 40 * sin$1(y / 3 * PI$1)) * 2 / 3;
|
|
4829
|
+
ret += (160 * sin$1(y / 12 * PI$1) + 320 * sin$1(y * PI$1 / 30)) * 2 / 3;
|
|
4830
|
+
return ret;
|
|
4831
|
+
}
|
|
4832
|
+
function transformLon(x, y) {
|
|
4833
|
+
let ret = 300 + x + 2 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * sqrt$1(abs$1(x));
|
|
4834
|
+
ret += (20 * sin$1(6 * x * PI$1) + 20 * sin$1(2 * x * PI$1)) * 2 / 3;
|
|
4835
|
+
ret += (20 * sin$1(x * PI$1) + 40 * sin$1(x / 3 * PI$1)) * 2 / 3;
|
|
4836
|
+
ret += (150 * sin$1(x / 12 * PI$1) + 300 * sin$1(x / 30 * PI$1)) * 2 / 3;
|
|
4837
|
+
return ret;
|
|
4838
|
+
}
|
|
4839
|
+
function delta(lon, lat) {
|
|
4840
|
+
let dLon = transformLon(lon - 105, lat - 35);
|
|
4841
|
+
let dLat = transformLat(lon - 105, lat - 35);
|
|
4842
|
+
const radLat = lat / 180 * PI$1;
|
|
4843
|
+
let magic = sin$1(radLat);
|
|
4844
|
+
magic = 1 - ee * magic * magic;
|
|
4845
|
+
const sqrtMagic = sqrt$1(magic);
|
|
4846
|
+
dLon = dLon * 180 / (a / sqrtMagic * cos$1(radLat) * PI$1);
|
|
4847
|
+
dLat = dLat * 180 / (a * (1 - ee) / (magic * sqrtMagic) * PI$1);
|
|
4848
|
+
return [dLon, dLat];
|
|
4849
|
+
}
|
|
4850
|
+
function WGS84ToGCJ02(coord) {
|
|
4851
|
+
const [lon, lat] = coord;
|
|
4852
|
+
if (!isInChinaBbox(lon, lat))
|
|
4853
|
+
return [lon, lat];
|
|
4854
|
+
const d = delta(lon, lat);
|
|
4855
|
+
return [lon + d[0], lat + d[1]];
|
|
4856
|
+
}
|
|
4857
|
+
function GCJ02ToWGS84(coord) {
|
|
4858
|
+
const [lon, lat] = coord;
|
|
4859
|
+
if (!isInChinaBbox(lon, lat))
|
|
4860
|
+
return [lon, lat];
|
|
4861
|
+
let [wgsLon, wgsLat] = [lon, lat];
|
|
4862
|
+
let tempPoint = WGS84ToGCJ02([wgsLon, wgsLat]);
|
|
4863
|
+
let dx = tempPoint[0] - lon;
|
|
4864
|
+
let dy = tempPoint[1] - lat;
|
|
4865
|
+
while (abs$1(dx) > 1e-6 || abs$1(dy) > 1e-6) {
|
|
4866
|
+
wgsLon -= dx;
|
|
4867
|
+
wgsLat -= dy;
|
|
4868
|
+
tempPoint = WGS84ToGCJ02([wgsLon, wgsLat]);
|
|
4869
|
+
dx = tempPoint[0] - lon;
|
|
4870
|
+
dy = tempPoint[1] - lat;
|
|
4871
|
+
}
|
|
4872
|
+
return [wgsLon, wgsLat];
|
|
4873
|
+
}
|
|
4874
|
+
const { sin, cos, atan2, sqrt, PI } = Math;
|
|
4875
|
+
const baiduFactor = PI * 3e3 / 180;
|
|
4876
|
+
function BD09ToGCJ02(coord) {
|
|
4877
|
+
const [lon, lat] = coord;
|
|
4878
|
+
const x = lon - 65e-4;
|
|
4879
|
+
const y = lat - 6e-3;
|
|
4880
|
+
const z = sqrt(x * x + y * y) - 2e-5 * sin(y * baiduFactor);
|
|
4881
|
+
const theta = atan2(y, x) - 3e-6 * cos(x * baiduFactor);
|
|
4882
|
+
const newLon = z * cos(theta);
|
|
4883
|
+
const newLat = z * sin(theta);
|
|
4884
|
+
return [newLon, newLat];
|
|
4885
|
+
}
|
|
4886
|
+
function GCJ02ToBD09(coord) {
|
|
4887
|
+
const [lon, lat] = coord;
|
|
4888
|
+
const x = lon;
|
|
4889
|
+
const y = lat;
|
|
4890
|
+
const z = sqrt(x * x + y * y) + 2e-5 * sin(y * baiduFactor);
|
|
4891
|
+
const theta = atan2(y, x) + 3e-6 * cos(x * baiduFactor);
|
|
4892
|
+
const newLon = z * cos(theta) + 65e-4;
|
|
4893
|
+
const newLat = z * sin(theta) + 6e-3;
|
|
4894
|
+
return [newLon, newLat];
|
|
4895
|
+
}
|
|
4896
|
+
const R2D = 180 / Math.PI;
|
|
4897
|
+
const D2R = Math.PI / 180;
|
|
4898
|
+
const A = 6378137;
|
|
4899
|
+
const MAXEXTENT = 20037508342789244e-9;
|
|
4900
|
+
function ESPG3857ToWGS84(xy) {
|
|
4901
|
+
return [
|
|
4902
|
+
xy[0] * R2D / A,
|
|
4903
|
+
(Math.PI * 0.5 - 2 * Math.atan(Math.exp(-xy[1] / A))) * R2D
|
|
4904
|
+
];
|
|
4905
|
+
}
|
|
4906
|
+
function WGS84ToEPSG3857(lonLat) {
|
|
4907
|
+
const adjusted = Math.abs(lonLat[0]) <= 180 ? lonLat[0] : lonLat[0] - (lonLat[0] < 0 ? -1 : 1) * 360;
|
|
4908
|
+
const xy = [
|
|
4909
|
+
A * adjusted * D2R,
|
|
4910
|
+
A * Math.log(Math.tan(Math.PI * 0.25 + 0.5 * lonLat[1] * D2R))
|
|
4911
|
+
];
|
|
4912
|
+
if (xy[0] > MAXEXTENT)
|
|
4913
|
+
xy[0] = MAXEXTENT;
|
|
4914
|
+
if (xy[0] < -MAXEXTENT)
|
|
4915
|
+
xy[0] = -MAXEXTENT;
|
|
4916
|
+
if (xy[1] > MAXEXTENT)
|
|
4917
|
+
xy[1] = MAXEXTENT;
|
|
4918
|
+
if (xy[1] < -MAXEXTENT)
|
|
4919
|
+
xy[1] = -MAXEXTENT;
|
|
4920
|
+
return xy;
|
|
4921
|
+
}
|
|
4922
|
+
const { abs } = Math;
|
|
4923
|
+
const MCBAND = [1289059486e-2, 836237787e-2, 5591021, 348198983e-2, 167804312e-2, 0];
|
|
4924
|
+
const LLBAND = [75, 60, 45, 30, 15, 0];
|
|
4925
|
+
const MC2LL = [
|
|
4926
|
+
[
|
|
4927
|
+
1410526172116255e-23,
|
|
4928
|
+
898305509648872e-20,
|
|
4929
|
+
-1.9939833816331,
|
|
4930
|
+
200.9824383106796,
|
|
4931
|
+
-187.2403703815547,
|
|
4932
|
+
91.6087516669843,
|
|
4933
|
+
-23.38765649603339,
|
|
4934
|
+
2.57121317296198,
|
|
4935
|
+
-0.03801003308653,
|
|
4936
|
+
173379812e-1
|
|
4937
|
+
],
|
|
4938
|
+
[
|
|
4939
|
+
-7435856389565537e-24,
|
|
4940
|
+
8983055097726239e-21,
|
|
4941
|
+
-0.78625201886289,
|
|
4942
|
+
96.32687599759846,
|
|
4943
|
+
-1.85204757529826,
|
|
4944
|
+
-59.36935905485877,
|
|
4945
|
+
47.40033549296737,
|
|
4946
|
+
-16.50741931063887,
|
|
4947
|
+
2.28786674699375,
|
|
4948
|
+
1026014486e-2
|
|
4949
|
+
],
|
|
4950
|
+
[
|
|
4951
|
+
-3030883460898826e-23,
|
|
4952
|
+
898305509983578e-20,
|
|
4953
|
+
0.30071316287616,
|
|
4954
|
+
59.74293618442277,
|
|
4955
|
+
7.357984074871,
|
|
4956
|
+
-25.38371002664745,
|
|
4957
|
+
13.45380521110908,
|
|
4958
|
+
-3.29883767235584,
|
|
4959
|
+
0.32710905363475,
|
|
4960
|
+
685681737e-2
|
|
4961
|
+
],
|
|
4962
|
+
[
|
|
4963
|
+
-1981981304930552e-23,
|
|
4964
|
+
8983055099779535e-21,
|
|
4965
|
+
0.03278182852591,
|
|
4966
|
+
40.31678527705744,
|
|
4967
|
+
0.65659298677277,
|
|
4968
|
+
-4.44255534477492,
|
|
4969
|
+
0.85341911805263,
|
|
4970
|
+
0.12923347998204,
|
|
4971
|
+
-0.04625736007561,
|
|
4972
|
+
448277706e-2
|
|
4973
|
+
],
|
|
4974
|
+
[
|
|
4975
|
+
309191371068437e-23,
|
|
4976
|
+
8983055096812155e-21,
|
|
4977
|
+
6995724062e-14,
|
|
4978
|
+
23.10934304144901,
|
|
4979
|
+
-23663490511e-14,
|
|
4980
|
+
-0.6321817810242,
|
|
4981
|
+
-0.00663494467273,
|
|
4982
|
+
0.03430082397953,
|
|
4983
|
+
-0.00466043876332,
|
|
4984
|
+
25551644e-1
|
|
4985
|
+
],
|
|
4986
|
+
[
|
|
4987
|
+
2890871144776878e-24,
|
|
4988
|
+
8983055095805407e-21,
|
|
4989
|
+
-3068298e-14,
|
|
4990
|
+
7.47137025468032,
|
|
4991
|
+
-353937994e-14,
|
|
4992
|
+
-0.02145144861037,
|
|
4993
|
+
-1234426596e-14,
|
|
4994
|
+
10322952773e-14,
|
|
4995
|
+
-323890364e-14,
|
|
4996
|
+
826088.5
|
|
4997
|
+
]
|
|
4998
|
+
];
|
|
4999
|
+
const LL2MC = [
|
|
5000
|
+
[
|
|
5001
|
+
-0.0015702102444,
|
|
5002
|
+
111320.7020616939,
|
|
5003
|
+
1704480524535203,
|
|
5004
|
+
-10338987376042340,
|
|
5005
|
+
26112667856603880,
|
|
5006
|
+
-35149669176653700,
|
|
5007
|
+
26595700718403920,
|
|
5008
|
+
-10725012454188240,
|
|
5009
|
+
1800819912950474,
|
|
5010
|
+
82.5
|
|
5011
|
+
],
|
|
5012
|
+
[
|
|
5013
|
+
8277824516172526e-19,
|
|
5014
|
+
111320.7020463578,
|
|
5015
|
+
6477955746671607e-7,
|
|
5016
|
+
-4082003173641316e-6,
|
|
5017
|
+
1077490566351142e-5,
|
|
5018
|
+
-1517187553151559e-5,
|
|
5019
|
+
1205306533862167e-5,
|
|
5020
|
+
-5124939663577472e-6,
|
|
5021
|
+
9133119359512032e-7,
|
|
5022
|
+
67.5
|
|
5023
|
+
],
|
|
5024
|
+
[
|
|
5025
|
+
0.00337398766765,
|
|
5026
|
+
111320.7020202162,
|
|
5027
|
+
4481351045890365e-9,
|
|
5028
|
+
-2339375119931662e-8,
|
|
5029
|
+
7968221547186455e-8,
|
|
5030
|
+
-1159649932797253e-7,
|
|
5031
|
+
9723671115602145e-8,
|
|
5032
|
+
-4366194633752821e-8,
|
|
5033
|
+
8477230501135234e-9,
|
|
5034
|
+
52.5
|
|
5035
|
+
],
|
|
5036
|
+
[
|
|
5037
|
+
0.00220636496208,
|
|
5038
|
+
111320.7020209128,
|
|
5039
|
+
51751.86112841131,
|
|
5040
|
+
3796837749470245e-9,
|
|
5041
|
+
992013.7397791013,
|
|
5042
|
+
-122195221711287e-8,
|
|
5043
|
+
1340652697009075e-9,
|
|
5044
|
+
-620943.6990984312,
|
|
5045
|
+
144416.9293806241,
|
|
5046
|
+
37.5
|
|
5047
|
+
],
|
|
5048
|
+
[
|
|
5049
|
+
-3441963504368392e-19,
|
|
5050
|
+
111320.7020576856,
|
|
5051
|
+
278.2353980772752,
|
|
5052
|
+
2485758690035394e-9,
|
|
5053
|
+
6070.750963243378,
|
|
5054
|
+
54821.18345352118,
|
|
5055
|
+
9540.606633304236,
|
|
5056
|
+
-2710.55326746645,
|
|
5057
|
+
1405.483844121726,
|
|
5058
|
+
22.5
|
|
5059
|
+
],
|
|
5060
|
+
[
|
|
5061
|
+
-3218135878613132e-19,
|
|
5062
|
+
111320.7020701615,
|
|
5063
|
+
0.00369383431289,
|
|
5064
|
+
823725.6402795718,
|
|
5065
|
+
0.46104986909093,
|
|
5066
|
+
2351.343141331292,
|
|
5067
|
+
1.58060784298199,
|
|
5068
|
+
8.77738589078284,
|
|
5069
|
+
0.37238884252424,
|
|
5070
|
+
7.45
|
|
5071
|
+
]
|
|
5072
|
+
];
|
|
5073
|
+
function transform$1(x, y, factors) {
|
|
5074
|
+
const cc = abs(y) / factors[9];
|
|
5075
|
+
let xt = factors[0] + factors[1] * abs(x);
|
|
5076
|
+
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);
|
|
5077
|
+
xt *= x < 0 ? -1 : 1;
|
|
5078
|
+
yt *= y < 0 ? -1 : 1;
|
|
5079
|
+
return [xt, yt];
|
|
5080
|
+
}
|
|
5081
|
+
function BD09toBD09MC(coord) {
|
|
5082
|
+
const [lng, lat] = coord;
|
|
5083
|
+
let factors = [];
|
|
5084
|
+
for (let i = 0; i < LLBAND.length; i++) {
|
|
5085
|
+
if (abs(lat) > LLBAND[i]) {
|
|
5086
|
+
factors = LL2MC[i];
|
|
5087
|
+
break;
|
|
5088
|
+
}
|
|
4829
5089
|
}
|
|
4830
|
-
|
|
4831
|
-
|
|
5090
|
+
return transform$1(lng, lat, factors);
|
|
5091
|
+
}
|
|
5092
|
+
function BD09MCtoBD09(coord) {
|
|
5093
|
+
const [x, y] = coord;
|
|
5094
|
+
let factors = [];
|
|
5095
|
+
for (let i = 0; i < MCBAND.length; i++) {
|
|
5096
|
+
if (y >= MCBAND[i]) {
|
|
5097
|
+
factors = MC2LL[i];
|
|
5098
|
+
break;
|
|
5099
|
+
}
|
|
4832
5100
|
}
|
|
4833
|
-
return
|
|
4834
|
-
}
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
const { toGcj02 } = useMapGCJ02();
|
|
4854
|
-
let isOnLoadTriggered = false;
|
|
4855
|
-
const loading = ref(false);
|
|
4856
|
-
const readyRef = ref(false);
|
|
4857
|
-
const errorRef = ref();
|
|
4858
|
-
const coordinateRef = ref({
|
|
4859
|
-
accuracy: 0,
|
|
4860
|
-
altitude: 0,
|
|
4861
|
-
altitudeAccuracy: 0,
|
|
4862
|
-
heading: 0,
|
|
4863
|
-
latitude: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _a : 0,
|
|
4864
|
-
longitude: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _b : 0,
|
|
4865
|
-
speed: 0
|
|
4866
|
-
});
|
|
4867
|
-
const positionRef = ref([coordinateRef.value.longitude, coordinateRef.value.latitude]);
|
|
4868
|
-
window.triggerGeoError = (code) => {
|
|
4869
|
-
onError == null ? void 0 : onError(createCustomGeolocationPositionError(Date.now().toString(), code));
|
|
5101
|
+
return transform$1(x, y, factors);
|
|
5102
|
+
}
|
|
5103
|
+
function assert(condition, msg) {
|
|
5104
|
+
if (!condition)
|
|
5105
|
+
throw new Error(msg);
|
|
5106
|
+
}
|
|
5107
|
+
function isArray(input) {
|
|
5108
|
+
return !!input && Object.prototype.toString.call(input) === "[object Array]";
|
|
5109
|
+
}
|
|
5110
|
+
function isNumber(input) {
|
|
5111
|
+
return !isNaN(Number(input)) && input !== null && !isArray(input);
|
|
5112
|
+
}
|
|
5113
|
+
function compose(...funcs) {
|
|
5114
|
+
const start = funcs.length - 1;
|
|
5115
|
+
return function(...args) {
|
|
5116
|
+
let i = start;
|
|
5117
|
+
let result = funcs[start].apply(null, args);
|
|
5118
|
+
while (i--)
|
|
5119
|
+
result = funcs[i].call(null, result);
|
|
5120
|
+
return result;
|
|
4870
5121
|
};
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
5122
|
+
}
|
|
5123
|
+
function coordEach(geojson, callback, excludeWrapCoord = false) {
|
|
5124
|
+
if (geojson === null)
|
|
5125
|
+
return;
|
|
5126
|
+
let j;
|
|
5127
|
+
let k;
|
|
5128
|
+
let l;
|
|
5129
|
+
let geometry;
|
|
5130
|
+
let coords;
|
|
5131
|
+
let stopG;
|
|
5132
|
+
let wrapShrink = 0;
|
|
5133
|
+
let coordIndex = 0;
|
|
5134
|
+
let geometryMaybeCollection;
|
|
5135
|
+
let isGeometryCollection;
|
|
5136
|
+
const { type: type2 } = geojson;
|
|
5137
|
+
const isFeatureCollection = type2 === "FeatureCollection";
|
|
5138
|
+
const isFeature = type2 === "Feature";
|
|
5139
|
+
const stop = isFeatureCollection ? geojson.features.length : 1;
|
|
5140
|
+
for (let featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
5141
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
5142
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
5143
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
5144
|
+
for (let geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
5145
|
+
let multiFeatureIndex = 0;
|
|
5146
|
+
let geometryIndex = 0;
|
|
5147
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
5148
|
+
if (geometry === null)
|
|
5149
|
+
continue;
|
|
5150
|
+
const geomType = geometry.type;
|
|
5151
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
5152
|
+
switch (geomType) {
|
|
5153
|
+
case null:
|
|
5154
|
+
break;
|
|
5155
|
+
case "Point":
|
|
5156
|
+
coords = geometry.coordinates;
|
|
5157
|
+
if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
5158
|
+
return false;
|
|
5159
|
+
coordIndex++;
|
|
5160
|
+
multiFeatureIndex++;
|
|
5161
|
+
break;
|
|
5162
|
+
case "LineString":
|
|
5163
|
+
case "MultiPoint":
|
|
5164
|
+
coords = geometry.coordinates;
|
|
5165
|
+
for (j = 0; j < coords.length; j++) {
|
|
5166
|
+
if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
5167
|
+
return false;
|
|
5168
|
+
coordIndex++;
|
|
5169
|
+
if (geomType === "MultiPoint")
|
|
5170
|
+
multiFeatureIndex++;
|
|
4884
5171
|
}
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
5172
|
+
if (geomType === "LineString")
|
|
5173
|
+
multiFeatureIndex++;
|
|
5174
|
+
break;
|
|
5175
|
+
case "Polygon":
|
|
5176
|
+
case "MultiLineString":
|
|
5177
|
+
coords = geometry.coordinates;
|
|
5178
|
+
for (j = 0; j < coords.length; j++) {
|
|
5179
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
5180
|
+
if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
5181
|
+
return false;
|
|
5182
|
+
coordIndex++;
|
|
5183
|
+
}
|
|
5184
|
+
if (geomType === "MultiLineString")
|
|
5185
|
+
multiFeatureIndex++;
|
|
5186
|
+
if (geomType === "Polygon")
|
|
5187
|
+
geometryIndex++;
|
|
4898
5188
|
}
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
5189
|
+
if (geomType === "Polygon")
|
|
5190
|
+
multiFeatureIndex++;
|
|
5191
|
+
break;
|
|
5192
|
+
case "MultiPolygon":
|
|
5193
|
+
coords = geometry.coordinates;
|
|
5194
|
+
for (j = 0; j < coords.length; j++) {
|
|
5195
|
+
geometryIndex = 0;
|
|
5196
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
5197
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
5198
|
+
if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
5199
|
+
return false;
|
|
5200
|
+
coordIndex++;
|
|
5201
|
+
}
|
|
5202
|
+
geometryIndex++;
|
|
5203
|
+
}
|
|
5204
|
+
multiFeatureIndex++;
|
|
4905
5205
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
isOnLoadTriggered = true;
|
|
4912
|
-
onLoadDefault == null ? void 0 : onLoadDefault({ position });
|
|
5206
|
+
break;
|
|
5207
|
+
case "GeometryCollection":
|
|
5208
|
+
for (j = 0; j < geometry.geometries.length; j++) {
|
|
5209
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
5210
|
+
return false;
|
|
4913
5211
|
}
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
},
|
|
4919
|
-
{ immediate: true }
|
|
4920
|
-
);
|
|
4921
|
-
return {
|
|
4922
|
-
geoError: errorRef,
|
|
4923
|
-
geoPosition: positionRef,
|
|
4924
|
-
geoCoordinate: coordinateRef,
|
|
4925
|
-
geoLoading: loading,
|
|
4926
|
-
geoReady: readyRef
|
|
4927
|
-
};
|
|
4928
|
-
};
|
|
4929
|
-
const useHeycarAmap = () => {
|
|
4930
|
-
const amapRef = shallowRef();
|
|
4931
|
-
const amapElementRef = shallowRef();
|
|
4932
|
-
const { apiMapDistanceVwOfPoints } = useMapLngLatToVw({ mapRef: amapRef });
|
|
4933
|
-
const setMap = (map) => {
|
|
4934
|
-
amapRef.value = map;
|
|
4935
|
-
amapElementRef.value = map == null ? void 0 : map.getContainer();
|
|
4936
|
-
};
|
|
4937
|
-
const panTo = async (value) => {
|
|
4938
|
-
const amap2 = amapRef.value;
|
|
4939
|
-
if (!(amap2 == null ? void 0 : amap2.amap))
|
|
4940
|
-
return;
|
|
4941
|
-
const { lng, lat } = amap2.getCenter();
|
|
4942
|
-
const distanceVw = apiMapDistanceVwOfPoints(value, [lng, lat]);
|
|
4943
|
-
const shouldAnimate = distanceVw < MAX_ANIMATION_DISTANCE_VW;
|
|
4944
|
-
if (shouldAnimate) {
|
|
4945
|
-
const duration = distanceVw2animationDuration(distanceVw);
|
|
4946
|
-
amap2.panTo(value, duration);
|
|
4947
|
-
await sleep(duration);
|
|
4948
|
-
} else {
|
|
4949
|
-
amap2.setCenter(value, true);
|
|
5212
|
+
break;
|
|
5213
|
+
default:
|
|
5214
|
+
throw new Error("Unknown Geometry Type");
|
|
5215
|
+
}
|
|
4950
5216
|
}
|
|
4951
|
-
}
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
const
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5219
|
+
var CRSTypes;
|
|
5220
|
+
(function(CRSTypes2) {
|
|
5221
|
+
CRSTypes2["WGS84"] = "WGS84";
|
|
5222
|
+
CRSTypes2["WGS1984"] = "WGS84";
|
|
5223
|
+
CRSTypes2["EPSG4326"] = "WGS84";
|
|
5224
|
+
CRSTypes2["GCJ02"] = "GCJ02";
|
|
5225
|
+
CRSTypes2["AMap"] = "GCJ02";
|
|
5226
|
+
CRSTypes2["BD09"] = "BD09";
|
|
5227
|
+
CRSTypes2["BD09LL"] = "BD09";
|
|
5228
|
+
CRSTypes2["Baidu"] = "BD09";
|
|
5229
|
+
CRSTypes2["BMap"] = "BD09";
|
|
5230
|
+
CRSTypes2["BD09MC"] = "BD09MC";
|
|
5231
|
+
CRSTypes2["BD09Meter"] = "BD09MC";
|
|
5232
|
+
CRSTypes2["EPSG3857"] = "EPSG3857";
|
|
5233
|
+
CRSTypes2["EPSG900913"] = "EPSG3857";
|
|
5234
|
+
CRSTypes2["EPSG102100"] = "EPSG3857";
|
|
5235
|
+
CRSTypes2["WebMercator"] = "EPSG3857";
|
|
5236
|
+
CRSTypes2["WM"] = "EPSG3857";
|
|
5237
|
+
})(CRSTypes || (CRSTypes = {}));
|
|
5238
|
+
const WGS84 = {
|
|
5239
|
+
to: {
|
|
5240
|
+
[CRSTypes.GCJ02]: WGS84ToGCJ02,
|
|
5241
|
+
[CRSTypes.BD09]: compose(GCJ02ToBD09, WGS84ToGCJ02),
|
|
5242
|
+
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09, WGS84ToGCJ02),
|
|
5243
|
+
[CRSTypes.EPSG3857]: WGS84ToEPSG3857
|
|
5244
|
+
}
|
|
5245
|
+
};
|
|
5246
|
+
const GCJ02 = {
|
|
5247
|
+
to: {
|
|
5248
|
+
[CRSTypes.WGS84]: GCJ02ToWGS84,
|
|
5249
|
+
[CRSTypes.BD09]: GCJ02ToBD09,
|
|
5250
|
+
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09),
|
|
5251
|
+
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84)
|
|
5252
|
+
}
|
|
5253
|
+
};
|
|
5254
|
+
const BD09 = {
|
|
5255
|
+
to: {
|
|
5256
|
+
[CRSTypes.WGS84]: compose(GCJ02ToWGS84, BD09ToGCJ02),
|
|
5257
|
+
[CRSTypes.GCJ02]: BD09ToGCJ02,
|
|
5258
|
+
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84, BD09ToGCJ02),
|
|
5259
|
+
[CRSTypes.BD09MC]: BD09toBD09MC
|
|
5260
|
+
}
|
|
5261
|
+
};
|
|
5262
|
+
const EPSG3857 = {
|
|
5263
|
+
to: {
|
|
5264
|
+
[CRSTypes.WGS84]: ESPG3857ToWGS84,
|
|
5265
|
+
[CRSTypes.GCJ02]: compose(WGS84ToGCJ02, ESPG3857ToWGS84),
|
|
5266
|
+
[CRSTypes.BD09]: compose(GCJ02ToBD09, WGS84ToGCJ02, ESPG3857ToWGS84),
|
|
5267
|
+
[CRSTypes.BD09MC]: compose(BD09toBD09MC, GCJ02ToBD09, WGS84ToGCJ02, ESPG3857ToWGS84)
|
|
5268
|
+
}
|
|
5269
|
+
};
|
|
5270
|
+
const BD09MC = {
|
|
5271
|
+
to: {
|
|
5272
|
+
[CRSTypes.WGS84]: compose(GCJ02ToWGS84, BD09ToGCJ02, BD09MCtoBD09),
|
|
5273
|
+
[CRSTypes.GCJ02]: compose(BD09ToGCJ02, BD09MCtoBD09),
|
|
5274
|
+
[CRSTypes.EPSG3857]: compose(WGS84ToEPSG3857, GCJ02ToWGS84, BD09ToGCJ02, BD09MCtoBD09),
|
|
5275
|
+
[CRSTypes.BD09]: BD09MCtoBD09
|
|
5276
|
+
}
|
|
5277
|
+
};
|
|
5278
|
+
const crsMap = {
|
|
5279
|
+
WGS84,
|
|
5280
|
+
GCJ02,
|
|
5281
|
+
BD09,
|
|
5282
|
+
EPSG3857,
|
|
5283
|
+
BD09MC
|
|
5284
|
+
};
|
|
5285
|
+
var crsMap$1 = crsMap;
|
|
5286
|
+
function transform(input, crsFrom, crsTo) {
|
|
5287
|
+
assert(!!input, "The args[0] input coordinate is required");
|
|
5288
|
+
assert(!!crsFrom, "The args[1] original coordinate system is required");
|
|
5289
|
+
assert(!!crsTo, "The args[2] target coordinate system is required");
|
|
5290
|
+
if (crsFrom === crsTo)
|
|
5291
|
+
return input;
|
|
5292
|
+
const from = crsMap$1[crsFrom];
|
|
5293
|
+
assert(!!from, `Invalid original coordinate system: ${crsFrom}`);
|
|
5294
|
+
const to = from.to[crsTo];
|
|
5295
|
+
assert(!!to, `Invalid target coordinate system: ${crsTo}`);
|
|
5296
|
+
const type2 = typeof input;
|
|
5297
|
+
assert(type2 === "string" || type2 === "object", `Invalid input coordinate type: ${type2}`);
|
|
5298
|
+
if (type2 === "string") {
|
|
5299
|
+
try {
|
|
5300
|
+
input = JSON.parse(input);
|
|
5301
|
+
} catch (e) {
|
|
5302
|
+
throw new Error(`Invalid input coordinate: ${input}`);
|
|
4995
5303
|
}
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
if (baseLng !== lng || baseLat !== lat)
|
|
5018
|
-
return;
|
|
5019
|
-
handleDragEndWithAnimationEnd(target);
|
|
5020
|
-
}, DRAGEND_DETECTING_ANIMATION_DELAY);
|
|
5021
|
-
};
|
|
5022
|
-
const handleMoveEnd = (_, { target }) => {
|
|
5023
|
-
if (!isDragEndWaitingMovingEndRef.value)
|
|
5024
|
-
return;
|
|
5025
|
-
handleDragEndWithAnimationEnd(target);
|
|
5026
|
-
};
|
|
5027
|
-
watchPostEffectForAMapEvent(mapRef, {}, handleZoomStart, [
|
|
5028
|
-
"onZoomStart"
|
|
5029
|
-
]);
|
|
5030
|
-
watchPostEffectForAMapEvent(mapRef, {}, emitDragStart, [
|
|
5031
|
-
"onDragStart"
|
|
5032
|
-
]);
|
|
5033
|
-
watchPostEffectForAMapEvent(mapRef, {}, emitDragEnd, [
|
|
5034
|
-
"onDragEnd"
|
|
5035
|
-
]);
|
|
5036
|
-
watchPostEffectForAMapEvent(mapRef, {}, handleMoveEnd, [
|
|
5037
|
-
"onMoveend"
|
|
5038
|
-
]);
|
|
5039
|
-
return { centerRef, isDragging };
|
|
5040
|
-
};
|
|
5041
|
-
const useGmapDrag = (props) => {
|
|
5042
|
-
const { mapRef, onChange } = props;
|
|
5043
|
-
const centerRef = ref([0, 0]);
|
|
5044
|
-
const isDragging = ref(false);
|
|
5045
|
-
const emitDragStart = () => {
|
|
5046
|
-
pipeAsync(() => {
|
|
5047
|
-
isDragging.value = true;
|
|
5048
|
-
})();
|
|
5049
|
-
};
|
|
5050
|
-
const emitDragEnd = async () => {
|
|
5051
|
-
var _a, _b;
|
|
5052
|
-
isDragging.value = false;
|
|
5053
|
-
const center = (_a = mapRef.value) == null ? void 0 : _a.getCenter();
|
|
5054
|
-
const lng = center == null ? void 0 : center.lng();
|
|
5055
|
-
const lat = center == null ? void 0 : center.lat();
|
|
5056
|
-
centerRef.value = [lng, lat];
|
|
5057
|
-
(_b = pipeAsync(onChange)) == null ? void 0 : _b([lng, lat]);
|
|
5058
|
-
};
|
|
5059
|
-
watchPostEffectForGMapEvent(mapRef, {}, emitDragStart, [
|
|
5060
|
-
"onDragStart"
|
|
5061
|
-
]);
|
|
5062
|
-
watchPostEffectForGMapEvent(mapRef, {}, emitDragEnd, [
|
|
5063
|
-
"onDragEnd"
|
|
5064
|
-
]);
|
|
5065
|
-
return { centerRef, isDragging };
|
|
5066
|
-
};
|
|
5067
|
-
const useMapDrag = (props) => {
|
|
5068
|
-
const { supplier } = useMapSupplier();
|
|
5069
|
-
return supplier === "gmap" ? useGmapDrag(props) : useAmapDrag(props);
|
|
5070
|
-
};
|
|
5071
|
-
const useAmapGeometry = () => {
|
|
5072
|
-
const payload = useMapSupplier();
|
|
5073
|
-
const apiMapDistance = (from, to) => {
|
|
5074
|
-
if (payload.status !== Status.SUCCESS)
|
|
5075
|
-
return void 0;
|
|
5076
|
-
return AMap.GeometryUtil.distance(from, to);
|
|
5077
|
-
};
|
|
5078
|
-
const apiMapDistanceToLine = (from, line) => {
|
|
5079
|
-
if (payload.status !== Status.SUCCESS)
|
|
5080
|
-
return void 0;
|
|
5081
|
-
return AMap.GeometryUtil.distanceToLine(from, line);
|
|
5082
|
-
};
|
|
5083
|
-
const apiMapDistanceOfLine = (line) => {
|
|
5084
|
-
if (payload.status !== Status.SUCCESS)
|
|
5085
|
-
return void 0;
|
|
5086
|
-
return AMap.GeometryUtil.distanceOfLine(line);
|
|
5087
|
-
};
|
|
5088
|
-
const apiMapIsPointInRing = (point, path) => {
|
|
5089
|
-
if (payload.status !== Status.SUCCESS)
|
|
5090
|
-
return void 0;
|
|
5091
|
-
return AMap.GeometryUtil.isPointInRing(point, path);
|
|
5092
|
-
};
|
|
5093
|
-
return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
|
|
5094
|
-
};
|
|
5095
|
-
const useGmapGeometry = () => {
|
|
5096
|
-
const payload = useMapSupplier();
|
|
5097
|
-
const apiMapDistance = (from, to) => {
|
|
5098
|
-
if (payload.status !== Status.SUCCESS)
|
|
5099
|
-
return void 0;
|
|
5100
|
-
return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
|
|
5101
|
-
};
|
|
5102
|
-
const apiMapDistanceToLine = (from, line) => {
|
|
5103
|
-
if (payload.status !== Status.SUCCESS)
|
|
5104
|
-
return void 0;
|
|
5105
|
-
return 0;
|
|
5106
|
-
};
|
|
5107
|
-
const apiMapDistanceOfLine = (line) => {
|
|
5108
|
-
if (payload.status !== Status.SUCCESS)
|
|
5109
|
-
return void 0;
|
|
5110
|
-
return google.maps.geometry.spherical.computeLength(line.map(vec2lnglat));
|
|
5111
|
-
};
|
|
5112
|
-
const apiMapIsPointInRing = (point, path) => {
|
|
5113
|
-
if (payload.status !== Status.SUCCESS)
|
|
5114
|
-
return void 0;
|
|
5115
|
-
const polygon = new google.maps.Polygon({ paths: path.map(vec2lnglat) });
|
|
5116
|
-
return google.maps.geometry.poly.containsLocation(vec2lnglat(point), polygon);
|
|
5117
|
-
};
|
|
5118
|
-
return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
|
|
5119
|
-
};
|
|
5120
|
-
const useMapGeometry = () => {
|
|
5121
|
-
const { supplier } = useMapSupplier();
|
|
5122
|
-
return supplier === "gmap" ? useGmapGeometry() : useAmapGeometry();
|
|
5123
|
-
};
|
|
5304
|
+
}
|
|
5305
|
+
let isPosition = false;
|
|
5306
|
+
if (isArray(input)) {
|
|
5307
|
+
assert(input.length >= 2, `Invalid input coordinate: ${input}`);
|
|
5308
|
+
assert(isNumber(input[0]) && isNumber(input[1]), `Invalid input coordinate: ${input}`);
|
|
5309
|
+
input = input.map(Number);
|
|
5310
|
+
isPosition = true;
|
|
5311
|
+
}
|
|
5312
|
+
const convert = to;
|
|
5313
|
+
if (isPosition)
|
|
5314
|
+
return convert(input);
|
|
5315
|
+
coordEach(input, (coord) => {
|
|
5316
|
+
[coord[0], coord[1]] = convert(coord);
|
|
5317
|
+
});
|
|
5318
|
+
return input;
|
|
5319
|
+
}
|
|
5320
|
+
const exported = Object.assign(Object.assign({}, CRSTypes), {
|
|
5321
|
+
// 兼容原来gcoord.WGS84的使用方式
|
|
5322
|
+
CRSTypes,
|
|
5323
|
+
transform
|
|
5324
|
+
});
|
|
5124
5325
|
const chinaBounds = [
|
|
5125
5326
|
[
|
|
5126
5327
|
108.03446,
|
|
@@ -6589,26 +6790,367 @@ const chinaBounds = [
|
|
|
6589
6790
|
];
|
|
6590
6791
|
const useAmapInChina = () => {
|
|
6591
6792
|
const payload = useMapSupplier();
|
|
6592
|
-
const inChina = (point) => {
|
|
6793
|
+
const inChina = (point) => {
|
|
6794
|
+
if (payload.status !== Status.SUCCESS)
|
|
6795
|
+
return false;
|
|
6796
|
+
return AMap.GeometryUtil.isPointInRing(point, chinaBounds);
|
|
6797
|
+
};
|
|
6798
|
+
return { inChina };
|
|
6799
|
+
};
|
|
6800
|
+
const useGmapInChina = () => {
|
|
6801
|
+
const payload = useMapSupplier();
|
|
6802
|
+
const inChina = (point) => {
|
|
6803
|
+
if (payload.status !== Status.SUCCESS)
|
|
6804
|
+
return false;
|
|
6805
|
+
const chinaPolygon = new google.maps.Polygon({ paths: chinaBounds });
|
|
6806
|
+
return google.maps.geometry.poly.containsLocation(vec2lnglat(point), chinaPolygon);
|
|
6807
|
+
};
|
|
6808
|
+
return { inChina };
|
|
6809
|
+
};
|
|
6810
|
+
const useMapInChina = () => {
|
|
6811
|
+
const { supplier } = useMapSupplier();
|
|
6812
|
+
return supplier === "gmap" ? useGmapInChina() : useAmapInChina();
|
|
6813
|
+
};
|
|
6814
|
+
const useLocalWgs2Gcj02 = () => {
|
|
6815
|
+
const { inChina } = useMapInChina();
|
|
6816
|
+
const toLocalGcj02Points = (points) => {
|
|
6817
|
+
return points.map((point) => {
|
|
6818
|
+
if (!inChina(point))
|
|
6819
|
+
return point;
|
|
6820
|
+
try {
|
|
6821
|
+
return exported.transform(point, exported.WGS84, exported.GCJ02);
|
|
6822
|
+
} catch (err) {
|
|
6823
|
+
console.error(`本地转换GCJ02失败: ${err == null ? void 0 : err.message}`);
|
|
6824
|
+
return point;
|
|
6825
|
+
}
|
|
6826
|
+
});
|
|
6827
|
+
};
|
|
6828
|
+
return { toLocalGcj02Points };
|
|
6829
|
+
};
|
|
6830
|
+
const useAmapGCJ02 = () => {
|
|
6831
|
+
const { readyPromise } = useMapSupplier();
|
|
6832
|
+
const { toLocalGcj02Points } = useLocalWgs2Gcj02();
|
|
6833
|
+
async function toGcj02Points(points) {
|
|
6834
|
+
await readyPromise;
|
|
6835
|
+
return new Promise((resolve) => {
|
|
6836
|
+
let isHandled = false;
|
|
6837
|
+
AMap.convertFrom(
|
|
6838
|
+
[...points],
|
|
6839
|
+
"gps",
|
|
6840
|
+
(_, result) => {
|
|
6841
|
+
if (isHandled)
|
|
6842
|
+
return;
|
|
6843
|
+
isHandled = true;
|
|
6844
|
+
if (result.info === "ok") {
|
|
6845
|
+
resolve(result.locations.map(lnglat2point));
|
|
6846
|
+
} else {
|
|
6847
|
+
console.warn("警告: 高德坐标转换请求失败,启用本地转换");
|
|
6848
|
+
resolve(toLocalGcj02Points(points));
|
|
6849
|
+
}
|
|
6850
|
+
}
|
|
6851
|
+
);
|
|
6852
|
+
setTimeout(() => {
|
|
6853
|
+
if (isHandled)
|
|
6854
|
+
return;
|
|
6855
|
+
isHandled = true;
|
|
6856
|
+
console.warn("警告: 高德坐标转换请求超时,启用本地转换");
|
|
6857
|
+
resolve(toLocalGcj02Points(points));
|
|
6858
|
+
}, AMAP_TO_GCJ02_TIMEOUT);
|
|
6859
|
+
});
|
|
6860
|
+
}
|
|
6861
|
+
function toGcj02(point) {
|
|
6862
|
+
return toGcj02Points([point]).then(([result]) => result);
|
|
6863
|
+
}
|
|
6864
|
+
return { toGcj02, toGcj02Points };
|
|
6865
|
+
};
|
|
6866
|
+
const useGmapGCJ02 = () => {
|
|
6867
|
+
const toGcj02 = async (point) => point;
|
|
6868
|
+
const toGcj02Points = async (points) => points;
|
|
6869
|
+
return { toGcj02, toGcj02Points };
|
|
6870
|
+
};
|
|
6871
|
+
const useMapGCJ02 = () => {
|
|
6872
|
+
const { supplier } = useMapSupplier();
|
|
6873
|
+
return supplier === "gmap" ? useGmapGCJ02() : useAmapGCJ02();
|
|
6874
|
+
};
|
|
6875
|
+
const GEO_TIMEOUT = 5e3;
|
|
6876
|
+
const singleGeoWatch = new SingleGeoWatch({
|
|
6877
|
+
timeout: GEO_TIMEOUT,
|
|
6878
|
+
maximumAge: 0,
|
|
6879
|
+
enableHighAccuracy: false
|
|
6880
|
+
});
|
|
6881
|
+
const useGeoLocation = (props) => {
|
|
6882
|
+
var _a, _b;
|
|
6883
|
+
const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
|
|
6884
|
+
const { toGcj02 } = useMapGCJ02();
|
|
6885
|
+
let isOnLoadTriggered = false;
|
|
6886
|
+
const loading = ref(false);
|
|
6887
|
+
const readyRef = ref(false);
|
|
6888
|
+
const errorRef = ref();
|
|
6889
|
+
const coordinateRef = ref({
|
|
6890
|
+
accuracy: 0,
|
|
6891
|
+
altitude: 0,
|
|
6892
|
+
altitudeAccuracy: 0,
|
|
6893
|
+
heading: 0,
|
|
6894
|
+
latitude: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _a : 0,
|
|
6895
|
+
longitude: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _b : 0,
|
|
6896
|
+
speed: 0
|
|
6897
|
+
});
|
|
6898
|
+
const positionRef = ref([coordinateRef.value.longitude, coordinateRef.value.latitude]);
|
|
6899
|
+
window.triggerGeoError = (code) => {
|
|
6900
|
+
onError == null ? void 0 : onError(createCustomGeolocationPositionError(Date.now().toString(), code));
|
|
6901
|
+
};
|
|
6902
|
+
watch(
|
|
6903
|
+
() => true,
|
|
6904
|
+
(_1, _2, onCleanup) => {
|
|
6905
|
+
const logStartTime = Date.now();
|
|
6906
|
+
loading.value = true;
|
|
6907
|
+
console.warn(`为了方便测试人员测试v4.3需求,开始请求 GPS 前提示,只会提示第一次`);
|
|
6908
|
+
let debugFlat = true;
|
|
6909
|
+
const debugNow = Date.now();
|
|
6910
|
+
const watchId = singleGeoWatch.watchPosition(
|
|
6911
|
+
async (position) => {
|
|
6912
|
+
if (debugFlat) {
|
|
6913
|
+
console.warn(`获取 GPS 成功, 用时 ${(Date.now() - debugNow) / 1e3} 秒`);
|
|
6914
|
+
debugFlat = false;
|
|
6915
|
+
}
|
|
6916
|
+
const duration = Date.now() - logStartTime;
|
|
6917
|
+
spaceLog("watchPosition", "success duration, position = ", duration, position);
|
|
6918
|
+
const coordinate = position.coords;
|
|
6919
|
+
const wgsPoint = [position.coords.longitude, position.coords.latitude];
|
|
6920
|
+
const point = await compatibleGeoPositionTransform(wgsPoint, toGcj02);
|
|
6921
|
+
coordinateRef.value = coordinate;
|
|
6922
|
+
positionRef.value = point;
|
|
6923
|
+
errorRef.value = void 0;
|
|
6924
|
+
if (loading.value) {
|
|
6925
|
+
loading.value = false;
|
|
6926
|
+
readyRef.value = true;
|
|
6927
|
+
isOnLoadTriggered = true;
|
|
6928
|
+
onLoad == null ? void 0 : onLoad({ position: point, coordinate });
|
|
6929
|
+
}
|
|
6930
|
+
onChange == null ? void 0 : onChange({ position: point, coordinate });
|
|
6931
|
+
},
|
|
6932
|
+
(error) => {
|
|
6933
|
+
if (debugFlat) {
|
|
6934
|
+
console.warn(`获取 GPS 失败, 用时 ${(Date.now() - debugNow) / 1e3} 秒`);
|
|
6935
|
+
debugFlat = false;
|
|
6936
|
+
}
|
|
6937
|
+
spaceLog("watchPosition", "error.message = ", error.message);
|
|
6938
|
+
loading.value = false;
|
|
6939
|
+
errorRef.value = error;
|
|
6940
|
+
const position = props == null ? void 0 : props.geoDefaultPosition;
|
|
6941
|
+
if (position && !isOnLoadTriggered) {
|
|
6942
|
+
isOnLoadTriggered = true;
|
|
6943
|
+
onLoadDefault == null ? void 0 : onLoadDefault({ position });
|
|
6944
|
+
}
|
|
6945
|
+
onError == null ? void 0 : onError(error);
|
|
6946
|
+
}
|
|
6947
|
+
);
|
|
6948
|
+
onCleanup(() => singleGeoWatch.clearWatch(watchId));
|
|
6949
|
+
},
|
|
6950
|
+
{ immediate: true }
|
|
6951
|
+
);
|
|
6952
|
+
return {
|
|
6953
|
+
geoError: errorRef,
|
|
6954
|
+
geoPosition: positionRef,
|
|
6955
|
+
geoCoordinate: coordinateRef,
|
|
6956
|
+
geoLoading: loading,
|
|
6957
|
+
geoReady: readyRef
|
|
6958
|
+
};
|
|
6959
|
+
};
|
|
6960
|
+
const useHeycarAmap = () => {
|
|
6961
|
+
const amapRef = shallowRef();
|
|
6962
|
+
const amapElementRef = shallowRef();
|
|
6963
|
+
const { apiMapDistanceVwOfPoints } = useMapLngLatToVw({ mapRef: amapRef });
|
|
6964
|
+
const setMap = (map) => {
|
|
6965
|
+
amapRef.value = map;
|
|
6966
|
+
amapElementRef.value = map == null ? void 0 : map.getContainer();
|
|
6967
|
+
};
|
|
6968
|
+
const panTo = async (value) => {
|
|
6969
|
+
const amap2 = amapRef.value;
|
|
6970
|
+
if (!(amap2 == null ? void 0 : amap2.amap))
|
|
6971
|
+
return;
|
|
6972
|
+
const { lng, lat } = amap2.getCenter();
|
|
6973
|
+
const distanceVw = apiMapDistanceVwOfPoints(value, [lng, lat]);
|
|
6974
|
+
const shouldAnimate = distanceVw < MAX_ANIMATION_DISTANCE_VW;
|
|
6975
|
+
if (shouldAnimate) {
|
|
6976
|
+
const duration = distanceVw2animationDuration(distanceVw);
|
|
6977
|
+
amap2.panTo(value, duration);
|
|
6978
|
+
await sleep(duration);
|
|
6979
|
+
} else {
|
|
6980
|
+
amap2.setCenter(value, true);
|
|
6981
|
+
}
|
|
6982
|
+
};
|
|
6983
|
+
return { mapRef: amapRef, mapElementRef: amapElementRef, panTo, setMap };
|
|
6984
|
+
};
|
|
6985
|
+
const useHeycarGamp = () => {
|
|
6986
|
+
const gmapRef = shallowRef();
|
|
6987
|
+
const gmapElementRef = shallowRef();
|
|
6988
|
+
const setMap = (map) => {
|
|
6989
|
+
gmapRef.value = map;
|
|
6990
|
+
gmapElementRef.value = map == null ? void 0 : map.getDiv();
|
|
6991
|
+
};
|
|
6992
|
+
const panTo = (value) => {
|
|
6993
|
+
var _a;
|
|
6994
|
+
return (_a = gmapRef == null ? void 0 : gmapRef.value) == null ? void 0 : _a.panTo(vec2lnglat(value));
|
|
6995
|
+
};
|
|
6996
|
+
return { mapRef: gmapRef, mapElementRef: gmapElementRef, panTo, setMap };
|
|
6997
|
+
};
|
|
6998
|
+
const useHeycarMap = () => {
|
|
6999
|
+
const { supplier } = useMapSupplier();
|
|
7000
|
+
return supplier === "gmap" ? useHeycarGamp() : useHeycarAmap();
|
|
7001
|
+
};
|
|
7002
|
+
const DRAGEND_DETECTING_ANIMATION_DELAY = 50;
|
|
7003
|
+
const useAmapDrag = (props) => {
|
|
7004
|
+
const { mapRef, onChange } = props;
|
|
7005
|
+
const centerRef = ref([0, 0]);
|
|
7006
|
+
const isDragging = ref(false);
|
|
7007
|
+
const isDragEndWaitingMovingEndRef = ref(false);
|
|
7008
|
+
let isZoom = false;
|
|
7009
|
+
let zoomStartCenter = void 0;
|
|
7010
|
+
let watchId = void 0;
|
|
7011
|
+
const emitDragStart = () => {
|
|
7012
|
+
pipeAsync(() => {
|
|
7013
|
+
isDragging.value = true;
|
|
7014
|
+
})();
|
|
7015
|
+
};
|
|
7016
|
+
const handleZoomStart = () => {
|
|
7017
|
+
var _a;
|
|
7018
|
+
isZoom = true;
|
|
7019
|
+
zoomStartCenter = (_a = mapRef.value) == null ? void 0 : _a.getCenter().toJSON();
|
|
7020
|
+
};
|
|
7021
|
+
const handleChange = (value) => {
|
|
7022
|
+
if (isZoom) {
|
|
7023
|
+
isZoom = false;
|
|
7024
|
+
if (isPointEqual(value, zoomStartCenter))
|
|
7025
|
+
return;
|
|
7026
|
+
}
|
|
7027
|
+
onChange == null ? void 0 : onChange(value);
|
|
7028
|
+
};
|
|
7029
|
+
const handleDragEndWithAnimationEnd = (target) => {
|
|
7030
|
+
var _a;
|
|
7031
|
+
isDragEndWaitingMovingEndRef.value = false;
|
|
7032
|
+
isDragging.value = false;
|
|
7033
|
+
const { lng, lat } = target.getCenter();
|
|
7034
|
+
spaceLog("onDragEndWithAnimationEnd", "[lng, lat] = ", [lng, lat]);
|
|
7035
|
+
centerRef.value = [lng, lat];
|
|
7036
|
+
(_a = pipeAsync(handleChange)) == null ? void 0 : _a([lng, lat]);
|
|
7037
|
+
};
|
|
7038
|
+
const emitDragEnd = (_, { target }) => {
|
|
7039
|
+
const { lng: baseLng, lat: baseLat } = target.getCenter();
|
|
7040
|
+
isDragEndWaitingMovingEndRef.value = true;
|
|
7041
|
+
if (watchId)
|
|
7042
|
+
clearTimeout(watchId);
|
|
7043
|
+
watchId = setTimeout(() => {
|
|
7044
|
+
watchId = void 0;
|
|
7045
|
+
const { lng, lat } = target.getCenter();
|
|
7046
|
+
if (!isDragEndWaitingMovingEndRef.value)
|
|
7047
|
+
return;
|
|
7048
|
+
if (baseLng !== lng || baseLat !== lat)
|
|
7049
|
+
return;
|
|
7050
|
+
handleDragEndWithAnimationEnd(target);
|
|
7051
|
+
}, DRAGEND_DETECTING_ANIMATION_DELAY);
|
|
7052
|
+
};
|
|
7053
|
+
const handleMoveEnd = (_, { target }) => {
|
|
7054
|
+
if (!isDragEndWaitingMovingEndRef.value)
|
|
7055
|
+
return;
|
|
7056
|
+
handleDragEndWithAnimationEnd(target);
|
|
7057
|
+
};
|
|
7058
|
+
watchPostEffectForAMapEvent(mapRef, {}, handleZoomStart, [
|
|
7059
|
+
"onZoomStart"
|
|
7060
|
+
]);
|
|
7061
|
+
watchPostEffectForAMapEvent(mapRef, {}, emitDragStart, [
|
|
7062
|
+
"onDragStart"
|
|
7063
|
+
]);
|
|
7064
|
+
watchPostEffectForAMapEvent(mapRef, {}, emitDragEnd, [
|
|
7065
|
+
"onDragEnd"
|
|
7066
|
+
]);
|
|
7067
|
+
watchPostEffectForAMapEvent(mapRef, {}, handleMoveEnd, [
|
|
7068
|
+
"onMoveend"
|
|
7069
|
+
]);
|
|
7070
|
+
return { centerRef, isDragging };
|
|
7071
|
+
};
|
|
7072
|
+
const useGmapDrag = (props) => {
|
|
7073
|
+
const { mapRef, onChange } = props;
|
|
7074
|
+
const centerRef = ref([0, 0]);
|
|
7075
|
+
const isDragging = ref(false);
|
|
7076
|
+
const emitDragStart = () => {
|
|
7077
|
+
pipeAsync(() => {
|
|
7078
|
+
isDragging.value = true;
|
|
7079
|
+
})();
|
|
7080
|
+
};
|
|
7081
|
+
const emitDragEnd = async () => {
|
|
7082
|
+
var _a, _b;
|
|
7083
|
+
isDragging.value = false;
|
|
7084
|
+
const center = (_a = mapRef.value) == null ? void 0 : _a.getCenter();
|
|
7085
|
+
const lng = center == null ? void 0 : center.lng();
|
|
7086
|
+
const lat = center == null ? void 0 : center.lat();
|
|
7087
|
+
centerRef.value = [lng, lat];
|
|
7088
|
+
(_b = pipeAsync(onChange)) == null ? void 0 : _b([lng, lat]);
|
|
7089
|
+
};
|
|
7090
|
+
watchPostEffectForGMapEvent(mapRef, {}, emitDragStart, [
|
|
7091
|
+
"onDragStart"
|
|
7092
|
+
]);
|
|
7093
|
+
watchPostEffectForGMapEvent(mapRef, {}, emitDragEnd, [
|
|
7094
|
+
"onDragEnd"
|
|
7095
|
+
]);
|
|
7096
|
+
return { centerRef, isDragging };
|
|
7097
|
+
};
|
|
7098
|
+
const useMapDrag = (props) => {
|
|
7099
|
+
const { supplier } = useMapSupplier();
|
|
7100
|
+
return supplier === "gmap" ? useGmapDrag(props) : useAmapDrag(props);
|
|
7101
|
+
};
|
|
7102
|
+
const useAmapGeometry = () => {
|
|
7103
|
+
const payload = useMapSupplier();
|
|
7104
|
+
const apiMapDistance = (from, to) => {
|
|
6593
7105
|
if (payload.status !== Status.SUCCESS)
|
|
6594
|
-
return
|
|
6595
|
-
return AMap.GeometryUtil.
|
|
7106
|
+
return void 0;
|
|
7107
|
+
return AMap.GeometryUtil.distance(from, to);
|
|
6596
7108
|
};
|
|
6597
|
-
|
|
7109
|
+
const apiMapDistanceToLine = (from, line) => {
|
|
7110
|
+
if (payload.status !== Status.SUCCESS)
|
|
7111
|
+
return void 0;
|
|
7112
|
+
return AMap.GeometryUtil.distanceToLine(from, line);
|
|
7113
|
+
};
|
|
7114
|
+
const apiMapDistanceOfLine = (line) => {
|
|
7115
|
+
if (payload.status !== Status.SUCCESS)
|
|
7116
|
+
return void 0;
|
|
7117
|
+
return AMap.GeometryUtil.distanceOfLine(line);
|
|
7118
|
+
};
|
|
7119
|
+
const apiMapIsPointInRing = (point, path) => {
|
|
7120
|
+
if (payload.status !== Status.SUCCESS)
|
|
7121
|
+
return void 0;
|
|
7122
|
+
return AMap.GeometryUtil.isPointInRing(point, path);
|
|
7123
|
+
};
|
|
7124
|
+
return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
|
|
6598
7125
|
};
|
|
6599
|
-
const
|
|
7126
|
+
const useGmapGeometry = () => {
|
|
6600
7127
|
const payload = useMapSupplier();
|
|
6601
|
-
const
|
|
7128
|
+
const apiMapDistance = (from, to) => {
|
|
6602
7129
|
if (payload.status !== Status.SUCCESS)
|
|
6603
|
-
return
|
|
6604
|
-
|
|
6605
|
-
return google.maps.geometry.poly.containsLocation(vec2lnglat(point), chinaPolygon);
|
|
7130
|
+
return void 0;
|
|
7131
|
+
return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
|
|
6606
7132
|
};
|
|
6607
|
-
|
|
7133
|
+
const apiMapDistanceToLine = (from, line) => {
|
|
7134
|
+
if (payload.status !== Status.SUCCESS)
|
|
7135
|
+
return void 0;
|
|
7136
|
+
return 0;
|
|
7137
|
+
};
|
|
7138
|
+
const apiMapDistanceOfLine = (line) => {
|
|
7139
|
+
if (payload.status !== Status.SUCCESS)
|
|
7140
|
+
return void 0;
|
|
7141
|
+
return google.maps.geometry.spherical.computeLength(line.map(vec2lnglat));
|
|
7142
|
+
};
|
|
7143
|
+
const apiMapIsPointInRing = (point, path) => {
|
|
7144
|
+
if (payload.status !== Status.SUCCESS)
|
|
7145
|
+
return void 0;
|
|
7146
|
+
const polygon = new google.maps.Polygon({ paths: path.map(vec2lnglat) });
|
|
7147
|
+
return google.maps.geometry.poly.containsLocation(vec2lnglat(point), polygon);
|
|
7148
|
+
};
|
|
7149
|
+
return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
|
|
6608
7150
|
};
|
|
6609
|
-
const
|
|
7151
|
+
const useMapGeometry = () => {
|
|
6610
7152
|
const { supplier } = useMapSupplier();
|
|
6611
|
-
return supplier === "gmap" ?
|
|
7153
|
+
return supplier === "gmap" ? useGmapGeometry() : useAmapGeometry();
|
|
6612
7154
|
};
|
|
6613
7155
|
const useUpdate = () => {
|
|
6614
7156
|
const idx = ref(0);
|