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