@heycar/heycars-map 0.9.20-timeout1 → 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 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-timeout1";
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$1 = 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$1(value)) {
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(a, b) {
1109
- return a === b || a !== a && b !== b;
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(a, b, indexOrKeyA, indexOrKeyB, parentA, parentB, cache) {
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 = !!a && typeof a === "object";
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(a, b, cache);
1171
+ return _comparator(a2, b, cache);
1171
1172
  }
1172
- var cachedA = cache.get(a);
1173
+ var cachedA = cache.get(a2);
1173
1174
  if (cachedA && cache.get(b)) {
1174
1175
  return cachedA === b;
1175
1176
  }
1176
- cache.set(a, b);
1177
- cache.set(b, a);
1178
- var result = _comparator(a, b, cache);
1179
- cache.delete(a);
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(a, b, isEqual, meta) {
1186
- var index = a.length;
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(a[index], b[index], index, index, a, b, meta)) {
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(a, b, isEqual, meta) {
1198
- var isValueEqual = a.size === b.size;
1199
- if (isValueEqual && a.size) {
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
- a.forEach(function(aValue, aKey) {
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, a, b, meta) && isEqual(aValue, bValue, aKey, bKey, a, b, meta);
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(a, b, isEqual, meta) {
1225
- var keysA = keys(a);
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(a);
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(a[key], b[key], key, key, a, b, meta)) {
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(a, b) {
1251
- return a.source === b.source && a.flags === b.flags;
1251
+ return function areRegExpsEqual2(a2, b) {
1252
+ return a2.source === b.source && a2.flags === b.flags;
1252
1253
  };
1253
1254
  }
1254
- return function areRegExpsEqualFallback(a, b) {
1255
- return a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.unicode === b.unicode && a.sticky === b.sticky && a.lastIndex === b.lastIndex;
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(a, b, isEqual, meta) {
1259
- var isValueEqual = a.size === b.size;
1260
- if (isValueEqual && a.size) {
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
- a.forEach(function(aValue, aKey) {
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, a, b, meta);
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(a, b, indexOrKeyA, indexOrKeyB, parentA, parentB, meta) {
1288
- return comparator(a, b, meta);
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(a, b, meta) {
1292
- if (a === b) {
1292
+ function comparator(a2, b, meta) {
1293
+ if (a2 === b) {
1293
1294
  return true;
1294
1295
  }
1295
- if (a && b && typeof a === "object" && typeof b === "object") {
1296
- if (isPlainObject(a) && isPlainObject(b)) {
1297
- return areObjectsEqual(a, b, isEqual, meta);
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(a);
1300
+ var aShape = Array.isArray(a2);
1300
1301
  var bShape = Array.isArray(b);
1301
1302
  if (aShape || bShape) {
1302
- return aShape === bShape && areArraysEqual(a, b, isEqual, meta);
1303
+ return aShape === bShape && areArraysEqual(a2, b, isEqual, meta);
1303
1304
  }
1304
- aShape = a instanceof Date;
1305
+ aShape = a2 instanceof Date;
1305
1306
  bShape = b instanceof Date;
1306
1307
  if (aShape || bShape) {
1307
- return aShape === bShape && sameValueZeroEqual(a.getTime(), b.getTime());
1308
+ return aShape === bShape && sameValueZeroEqual(a2.getTime(), b.getTime());
1308
1309
  }
1309
- aShape = a instanceof RegExp;
1310
+ aShape = a2 instanceof RegExp;
1310
1311
  bShape = b instanceof RegExp;
1311
1312
  if (aShape || bShape) {
1312
- return aShape === bShape && areRegExpsEqual(a, b);
1313
+ return aShape === bShape && areRegExpsEqual(a2, b);
1313
1314
  }
1314
- if (isPromiseLike(a) || isPromiseLike(b)) {
1315
- return a === b;
1315
+ if (isPromiseLike(a2) || isPromiseLike(b)) {
1316
+ return a2 === b;
1316
1317
  }
1317
1318
  if (HAS_MAP_SUPPORT) {
1318
- aShape = a instanceof Map;
1319
+ aShape = a2 instanceof Map;
1319
1320
  bShape = b instanceof Map;
1320
1321
  if (aShape || bShape) {
1321
- return aShape === bShape && areMapsEqual(a, b, isEqual, meta);
1322
+ return aShape === bShape && areMapsEqual(a2, b, isEqual, meta);
1322
1323
  }
1323
1324
  }
1324
1325
  if (HAS_SET_SUPPORT) {
1325
- aShape = a instanceof Set;
1326
+ aShape = a2 instanceof Set;
1326
1327
  bShape = b instanceof Set;
1327
1328
  if (aShape || bShape) {
1328
- return aShape === bShape && areSetsEqual(a, b, isEqual, meta);
1329
+ return aShape === bShape && areSetsEqual(a2, b, isEqual, meta);
1329
1330
  }
1330
1331
  }
1331
- if (a.valueOf !== valueOf || b.valueOf !== valueOf) {
1332
- return sameValueZeroEqual(a.valueOf(), b.valueOf());
1332
+ if (a2.valueOf !== valueOf || b.valueOf !== valueOf) {
1333
+ return sameValueZeroEqual(a2.valueOf(), b.valueOf());
1333
1334
  }
1334
- return areObjectsEqual(a, b, isEqual, meta);
1335
+ return areObjectsEqual(a2, b, isEqual, meta);
1335
1336
  }
1336
- return a !== a && b !== b;
1337
+ return a2 !== a2 && b !== b;
1337
1338
  }
1338
1339
  return comparator;
1339
1340
  }
@@ -1441,6 +1442,8 @@ const ZINDEX_GREEN_ZONE = 10;
1441
1442
  const TRACKS_MATCH_MAX_LENGTH = 3;
1442
1443
  const REGEO_TIMEOUT = 5e3;
1443
1444
  const GET_RECOMMEND_PLACE_TIMEOUT = 5e3;
1445
+ const GET_DEFAULT_CENTER_PLACE_TIMEOUT = 5e3;
1446
+ const AMAP_TO_GCJ02_TIMEOUT = 2e3;
1444
1447
  const IS_ENABLE_AUXILIARY_GRASP_ROAD = location.search.includes("enableAuxiliaryGraspRoad");
1445
1448
  const AMAP_DEFAULT_MARKER_ICON_URL = "https://webapi.amap.com/theme/v1.3/markers/b/mark_bs.png";
1446
1449
  var BRWOSER_PLATFORM = /* @__PURE__ */ ((BRWOSER_PLATFORM2) => {
@@ -1690,7 +1693,7 @@ const toTrackPoint = (maybeTrackPoint) => {
1690
1693
  return { lng, lat, angle, speed, timestamp };
1691
1694
  };
1692
1695
  const toTrackPoints = (maybeTrackPoints) => {
1693
- if (!isArray$1(maybeTrackPoints))
1696
+ if (!isArray$2(maybeTrackPoints))
1694
1697
  throwTypeError("TrackPoint[]", maybeTrackPoints);
1695
1698
  return maybeTrackPoints.map(toTrackPoint);
1696
1699
  };
@@ -1748,12 +1751,12 @@ const alipayMyGetLocationError2GeolocationPositionErrorCode = (code) => {
1748
1751
  const geoPositionError2businessTimeout = (error, platform) => {
1749
1752
  return platform !== BRWOSER_PLATFORM.WECHAT && platform !== BRWOSER_PLATFORM.WECHAT_MINIPROGRAM && error.code === GeolocationPositionError.TIMEOUT;
1750
1753
  };
1751
- const deepCompareEqualsForMaps = createComparator((deepEqual) => (a, b) => {
1752
- if (isLatLngLiteral(a) && isLatLngLiteral(b)) {
1753
- const result = isPlaceEqual(a, b);
1754
+ const deepCompareEqualsForMaps = createComparator((deepEqual) => (a2, b) => {
1755
+ if (isLatLngLiteral(a2) && isLatLngLiteral(b)) {
1756
+ const result = isPlaceEqual(a2, b);
1754
1757
  return result;
1755
1758
  }
1756
- return deepEqual(a, b);
1759
+ return deepEqual(a2, b);
1757
1760
  });
1758
1761
  function createDeepCompareMemoize() {
1759
1762
  let prev = void 0;
@@ -2111,28 +2114,28 @@ var dist = {
2111
2114
  (function(m, p) {
2112
2115
  module2.exports = p();
2113
2116
  })(commonjsGlobal, function() {
2114
- function m(a) {
2117
+ function m(a2) {
2115
2118
  var b2 = [];
2116
- a.AMapUI && b2.push(p(a.AMapUI));
2117
- a.Loca && b2.push(r(a.Loca));
2119
+ a2.AMapUI && b2.push(p(a2.AMapUI));
2120
+ a2.Loca && b2.push(r(a2.Loca));
2118
2121
  return Promise.all(b2);
2119
2122
  }
2120
- function p(a) {
2123
+ function p(a2) {
2121
2124
  return new Promise(function(h, c) {
2122
2125
  var f = [];
2123
- if (a.plugins)
2124
- for (var e = 0; e < a.plugins.length; e += 1)
2125
- -1 == d.AMapUI.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
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]);
2126
2129
  if (g.AMapUI === b.failed)
2127
2130
  c("前次请求 AMapUI 失败");
2128
2131
  else if (g.AMapUI === b.notload) {
2129
2132
  g.AMapUI = b.loading;
2130
- d.AMapUI.version = a.version || d.AMapUI.version;
2133
+ d.AMapUI.version = a2.version || d.AMapUI.version;
2131
2134
  e = d.AMapUI.version;
2132
2135
  var l = document.body || document.head, k = document.createElement("script");
2133
2136
  k.type = "text/javascript";
2134
2137
  k.src = "https://webapi.amap.com/ui/" + e + "/main.js";
2135
- k.onerror = function(a2) {
2138
+ k.onerror = function(a3) {
2136
2139
  g.AMapUI = b.failed;
2137
2140
  c("请求 AMapUI 失败");
2138
2141
  };
@@ -2140,9 +2143,9 @@ var dist = {
2140
2143
  g.AMapUI = b.loaded;
2141
2144
  if (f.length)
2142
2145
  window.AMapUI.loadUI(f, function() {
2143
- for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
2144
- var c2 = f[a2].split("/").slice(-1)[0];
2145
- window.AMapUI[c2] = arguments[a2];
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];
2146
2149
  }
2147
2150
  for (h(); n.AMapUI.length; )
2148
2151
  n.AMapUI.splice(0, 1)[0]();
@@ -2153,30 +2156,30 @@ var dist = {
2153
2156
  };
2154
2157
  l.appendChild(k);
2155
2158
  } else
2156
- g.AMapUI === b.loaded ? a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : f.length ? window.AMapUI.loadUI(f, function() {
2157
- for (var a2 = 0, b2 = f.length; a2 < b2; a2++) {
2158
- var c2 = f[a2].split("/").slice(-1)[0];
2159
- window.AMapUI[c2] = arguments[a2];
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];
2160
2163
  }
2161
2164
  h();
2162
- }) : h() : a.version && a.version !== d.AMapUI.version ? c("不允许多个版本 AMapUI 混用") : n.AMapUI.push(function(a2) {
2163
- a2 ? c(a2) : f.length ? window.AMapUI.loadUI(f, function() {
2164
- for (var a3 = 0, b2 = f.length; a3 < b2; a3++) {
2165
- var c2 = f[a3].split("/").slice(-1)[0];
2166
- window.AMapUI[c2] = arguments[a3];
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];
2167
2170
  }
2168
2171
  h();
2169
2172
  }) : h();
2170
2173
  });
2171
2174
  });
2172
2175
  }
2173
- function r(a) {
2176
+ function r(a2) {
2174
2177
  return new Promise(function(h, c) {
2175
2178
  if (g.Loca === b.failed)
2176
2179
  c("前次请求 Loca 失败");
2177
2180
  else if (g.Loca === b.notload) {
2178
2181
  g.Loca = b.loading;
2179
- d.Loca.version = a.version || d.Loca.version;
2182
+ d.Loca.version = a2.version || d.Loca.version;
2180
2183
  var f = d.Loca.version, e = d.AMap.version.startsWith("2"), l = f.startsWith("2");
2181
2184
  if (e && !l || !e && l)
2182
2185
  c("JSAPI 与 Loca 版本不对应!!");
@@ -2186,7 +2189,7 @@ var dist = {
2186
2189
  var k = document.createElement("script");
2187
2190
  k.type = "text/javascript";
2188
2191
  k.src = "https://webapi.amap.com/loca?v=" + f + "&key=" + e;
2189
- k.onerror = function(a2) {
2192
+ k.onerror = function(a3) {
2190
2193
  g.Loca = b.failed;
2191
2194
  c("请求 AMapUI 失败");
2192
2195
  };
@@ -2198,81 +2201,81 @@ var dist = {
2198
2201
  l.appendChild(k);
2199
2202
  }
2200
2203
  } else
2201
- g.Loca === b.loaded ? a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : h() : a.version && a.version !== d.Loca.version ? c("不允许多个版本 Loca 混用") : n.Loca.push(function(a2) {
2202
- a2 ? c(a2) : c();
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();
2203
2206
  });
2204
2207
  });
2205
2208
  }
2206
2209
  if (!window)
2207
2210
  throw Error("AMap JSAPI can only be used in Browser.");
2208
2211
  var b;
2209
- (function(a) {
2210
- a.notload = "notload";
2211
- a.loading = "loading";
2212
- a.loaded = "loaded";
2213
- a.failed = "failed";
2212
+ (function(a2) {
2213
+ a2.notload = "notload";
2214
+ a2.loading = "loading";
2215
+ a2.loaded = "loaded";
2216
+ a2.failed = "failed";
2214
2217
  })(b || (b = {}));
2215
- 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(a) {
2216
- "function" == typeof a && (g.AMap === b.loaded ? a(window.AMap) : q.push(a));
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));
2217
2220
  };
2218
- return { load: function(a) {
2221
+ return { load: function(a2) {
2219
2222
  return new Promise(function(h, c) {
2220
2223
  if (g.AMap == b.failed)
2221
2224
  c("");
2222
2225
  else if (g.AMap == b.notload) {
2223
- var f = a.key, e = a.version, l = a.plugins;
2226
+ var f = a2.key, e = a2.version, l = a2.plugins;
2224
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) {
2225
2228
  delete window.___onAPILoaded;
2226
2229
  if (d2)
2227
2230
  g.AMap = b.failed, c(d2);
2228
2231
  else
2229
- for (g.AMap = b.loaded, m(a).then(function() {
2232
+ for (g.AMap = b.loaded, m(a2).then(function() {
2230
2233
  h(window.AMap);
2231
2234
  })["catch"](c); q.length; )
2232
2235
  q.splice(0, 1)[0]();
2233
- }, 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(a2) {
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) {
2234
2237
  g.AMap = b.failed;
2235
- c(a2);
2238
+ c(a3);
2236
2239
  }, e.appendChild(l)) : c("请填写key");
2237
2240
  } else if (g.AMap == b.loaded)
2238
- if (a.key && a.key !== d.key)
2241
+ if (a2.key && a2.key !== d.key)
2239
2242
  c("多个不一致的 key");
2240
- else if (a.version && a.version !== d.AMap.version)
2243
+ else if (a2.version && a2.version !== d.AMap.version)
2241
2244
  c("不允许多个版本 JSAPI 混用");
2242
2245
  else {
2243
2246
  f = [];
2244
- if (a.plugins)
2245
- for (e = 0; e < a.plugins.length; e += 1)
2246
- -1 == d.AMap.plugins.indexOf(a.plugins[e]) && f.push(a.plugins[e]);
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]);
2247
2250
  if (f.length)
2248
2251
  window.AMap.plugin(f, function() {
2249
- m(a).then(function() {
2252
+ m(a2).then(function() {
2250
2253
  h(window.AMap);
2251
2254
  })["catch"](c);
2252
2255
  });
2253
2256
  else
2254
- m(a).then(function() {
2257
+ m(a2).then(function() {
2255
2258
  h(window.AMap);
2256
2259
  })["catch"](c);
2257
2260
  }
2258
- else if (a.key && a.key !== d.key)
2261
+ else if (a2.key && a2.key !== d.key)
2259
2262
  c("多个不一致的 key");
2260
- else if (a.version && a.version !== d.AMap.version)
2263
+ else if (a2.version && a2.version !== d.AMap.version)
2261
2264
  c("不允许多个版本 JSAPI 混用");
2262
2265
  else {
2263
2266
  var k = [];
2264
- if (a.plugins)
2265
- for (e = 0; e < a.plugins.length; e += 1)
2266
- -1 == d.AMap.plugins.indexOf(a.plugins[e]) && k.push(a.plugins[e]);
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]);
2267
2270
  t(function() {
2268
2271
  if (k.length)
2269
2272
  window.AMap.plugin(k, function() {
2270
- m(a).then(function() {
2273
+ m(a2).then(function() {
2271
2274
  h(window.AMap);
2272
2275
  })["catch"](c);
2273
2276
  });
2274
2277
  else
2275
- m(a).then(function() {
2278
+ m(a2).then(function() {
2276
2279
  h(window.AMap);
2277
2280
  })["catch"](c);
2278
2281
  });
@@ -2292,29 +2295,29 @@ var dist = {
2292
2295
  } };
2293
2296
  });
2294
2297
  })(dist);
2295
- var fastDeepEqual = function equal(a, b) {
2296
- if (a === b)
2298
+ var fastDeepEqual = function equal(a2, b) {
2299
+ if (a2 === b)
2297
2300
  return true;
2298
- if (a && b && typeof a == "object" && typeof b == "object") {
2299
- if (a.constructor !== b.constructor)
2301
+ if (a2 && b && typeof a2 == "object" && typeof b == "object") {
2302
+ if (a2.constructor !== b.constructor)
2300
2303
  return false;
2301
2304
  var length, i, keys2;
2302
- if (Array.isArray(a)) {
2303
- length = a.length;
2305
+ if (Array.isArray(a2)) {
2306
+ length = a2.length;
2304
2307
  if (length != b.length)
2305
2308
  return false;
2306
2309
  for (i = length; i-- !== 0; )
2307
- if (!equal(a[i], b[i]))
2310
+ if (!equal(a2[i], b[i]))
2308
2311
  return false;
2309
2312
  return true;
2310
2313
  }
2311
- if (a.constructor === RegExp)
2312
- return a.source === b.source && a.flags === b.flags;
2313
- if (a.valueOf !== Object.prototype.valueOf)
2314
- return a.valueOf() === b.valueOf();
2315
- if (a.toString !== Object.prototype.toString)
2316
- return a.toString() === b.toString();
2317
- keys2 = Object.keys(a);
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);
2318
2321
  length = keys2.length;
2319
2322
  if (length !== Object.keys(b).length)
2320
2323
  return false;
@@ -2323,12 +2326,12 @@ var fastDeepEqual = function equal(a, b) {
2323
2326
  return false;
2324
2327
  for (i = length; i-- !== 0; ) {
2325
2328
  var key = keys2[i];
2326
- if (!equal(a[key], b[key]))
2329
+ if (!equal(a2[key], b[key]))
2327
2330
  return false;
2328
2331
  }
2329
2332
  return true;
2330
2333
  }
2331
- return a !== a && b !== b;
2334
+ return a2 !== a2 && b !== b;
2332
2335
  };
2333
2336
  const DEFAULT_ID = "__googleMapsScriptId";
2334
2337
  var LoaderStatus;
@@ -4761,15 +4764,15 @@ function compatibleWathPosition(onSuccess, onError, option) {
4761
4764
  const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
4762
4765
  return () => navigator.geolocation.clearWatch(watchId);
4763
4766
  }
4764
- function compatibleGeoPositionTransform(position, transform) {
4767
+ function compatibleGeoPositionTransform(position, transform2) {
4765
4768
  const os = detectOSPlatform();
4766
4769
  const platform = detectBrowserPlatform();
4767
4770
  const wallet = detectAlipayWallet();
4768
4771
  if ((wallet === ALIPAY_WALLET.TNGD || wallet === ALIPAY_WALLET.TMN) && os === OS_PLATFORM.ANDROID)
4769
- return transform(position);
4772
+ return transform2(position);
4770
4773
  if (platform === BRWOSER_PLATFORM.ALIPAY || platform === BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM)
4771
4774
  return position;
4772
- return transform(position);
4775
+ return transform2(position);
4773
4776
  }
4774
4777
  class SingleGeoWatch {
4775
4778
  constructor(option) {
@@ -4810,318 +4813,517 @@ class SingleGeoWatch {
4810
4813
  );
4811
4814
  }
4812
4815
  }
4813
- const useAmapGCJ02 = () => {
4814
- const { readyPromise } = useMapSupplier();
4815
- async function toGcj02Points(points) {
4816
- await readyPromise;
4817
- return new Promise((resolve, reject) => {
4818
- AMap.convertFrom(
4819
- points,
4820
- "gps",
4821
- (_, result) => {
4822
- if (result.info === "ok") {
4823
- resolve(result.locations.map(lnglat2point));
4824
- } else {
4825
- reject();
4826
- }
4827
- }
4828
- );
4829
- });
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
+ }
4830
5091
  }
4831
- function toGcj02(point) {
4832
- return toGcj02Points([point]).then(([result]) => result);
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
+ }
4833
5102
  }
4834
- return { toGcj02, toGcj02Points };
4835
- };
4836
- const useGmapGCJ02 = () => {
4837
- const toGcj02 = async (point) => point;
4838
- const toGcj02Points = async (points) => points;
4839
- return { toGcj02, toGcj02Points };
4840
- };
4841
- const useMapGCJ02 = () => {
4842
- const { supplier } = useMapSupplier();
4843
- return supplier === "gmap" ? useGmapGCJ02() : useAmapGCJ02();
4844
- };
4845
- const GEO_TIMEOUT = 5e3;
4846
- const singleGeoWatch = new SingleGeoWatch({
4847
- timeout: GEO_TIMEOUT,
4848
- maximumAge: 0,
4849
- enableHighAccuracy: false
4850
- });
4851
- const useGeoLocation = (props) => {
4852
- var _a, _b;
4853
- const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
4854
- const { toGcj02 } = useMapGCJ02();
4855
- let isOnLoadTriggered = false;
4856
- const loading = Vue.ref(false);
4857
- const readyRef = Vue.ref(false);
4858
- const errorRef = Vue.ref();
4859
- const coordinateRef = Vue.ref({
4860
- accuracy: 0,
4861
- altitude: 0,
4862
- altitudeAccuracy: 0,
4863
- heading: 0,
4864
- latitude: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _a : 0,
4865
- longitude: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _b : 0,
4866
- speed: 0
4867
- });
4868
- const positionRef = Vue.ref([coordinateRef.value.longitude, coordinateRef.value.latitude]);
4869
- window.triggerGeoError = (code) => {
4870
- 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;
4871
5123
  };
4872
- Vue.watch(
4873
- () => true,
4874
- (_1, _2, onCleanup) => {
4875
- const logStartTime = Date.now();
4876
- loading.value = true;
4877
- console.warn(`为了方便测试人员测试v4.3需求,开始请求 GPS 前提示,只会提示第一次`);
4878
- let debugFlat = true;
4879
- const debugNow = Date.now();
4880
- const watchId = singleGeoWatch.watchPosition(
4881
- async (position) => {
4882
- if (debugFlat) {
4883
- console.warn(`获取 GPS 成功, 用时 ${(Date.now() - debugNow) / 1e3} 秒`);
4884
- debugFlat = false;
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++;
4885
5173
  }
4886
- const duration = Date.now() - logStartTime;
4887
- spaceLog("watchPosition", "success duration, position = ", duration, position);
4888
- const coordinate = position.coords;
4889
- const wgsPoint = [position.coords.longitude, position.coords.latitude];
4890
- const point = await compatibleGeoPositionTransform(wgsPoint, toGcj02);
4891
- coordinateRef.value = coordinate;
4892
- positionRef.value = point;
4893
- errorRef.value = void 0;
4894
- if (loading.value) {
4895
- loading.value = false;
4896
- readyRef.value = true;
4897
- isOnLoadTriggered = true;
4898
- onLoad == null ? void 0 : onLoad({ position: point, coordinate });
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++;
4899
5190
  }
4900
- onChange == null ? void 0 : onChange({ position: point, coordinate });
4901
- },
4902
- (error) => {
4903
- if (debugFlat) {
4904
- console.warn(`获取 GPS 失败, 用时 ${(Date.now() - debugNow) / 1e3} 秒`);
4905
- debugFlat = false;
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++;
4906
5207
  }
4907
- spaceLog("watchPosition", "error.message = ", error.message);
4908
- loading.value = false;
4909
- errorRef.value = error;
4910
- const position = props == null ? void 0 : props.geoDefaultPosition;
4911
- if (position && !isOnLoadTriggered) {
4912
- isOnLoadTriggered = true;
4913
- 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;
4914
5213
  }
4915
- onError == null ? void 0 : onError(error);
4916
- }
4917
- );
4918
- onCleanup(() => singleGeoWatch.clearWatch(watchId));
4919
- },
4920
- { immediate: true }
4921
- );
4922
- return {
4923
- geoError: errorRef,
4924
- geoPosition: positionRef,
4925
- geoCoordinate: coordinateRef,
4926
- geoLoading: loading,
4927
- geoReady: readyRef
4928
- };
4929
- };
4930
- const useHeycarAmap = () => {
4931
- const amapRef = Vue.shallowRef();
4932
- const amapElementRef = Vue.shallowRef();
4933
- const { apiMapDistanceVwOfPoints } = useMapLngLatToVw({ mapRef: amapRef });
4934
- const setMap = (map) => {
4935
- amapRef.value = map;
4936
- amapElementRef.value = map == null ? void 0 : map.getContainer();
4937
- };
4938
- const panTo = async (value) => {
4939
- const amap2 = amapRef.value;
4940
- if (!(amap2 == null ? void 0 : amap2.amap))
4941
- return;
4942
- const { lng, lat } = amap2.getCenter();
4943
- const distanceVw = apiMapDistanceVwOfPoints(value, [lng, lat]);
4944
- const shouldAnimate = distanceVw < MAX_ANIMATION_DISTANCE_VW;
4945
- if (shouldAnimate) {
4946
- const duration = distanceVw2animationDuration(distanceVw);
4947
- amap2.panTo(value, duration);
4948
- await sleep(duration);
4949
- } else {
4950
- amap2.setCenter(value, true);
5214
+ break;
5215
+ default:
5216
+ throw new Error("Unknown Geometry Type");
5217
+ }
4951
5218
  }
4952
- };
4953
- return { mapRef: amapRef, mapElementRef: amapElementRef, panTo, setMap };
4954
- };
4955
- const useHeycarGamp = () => {
4956
- const gmapRef = Vue.shallowRef();
4957
- const gmapElementRef = Vue.shallowRef();
4958
- const setMap = (map) => {
4959
- gmapRef.value = map;
4960
- gmapElementRef.value = map == null ? void 0 : map.getDiv();
4961
- };
4962
- const panTo = (value) => {
4963
- var _a;
4964
- return (_a = gmapRef == null ? void 0 : gmapRef.value) == null ? void 0 : _a.panTo(vec2lnglat(value));
4965
- };
4966
- return { mapRef: gmapRef, mapElementRef: gmapElementRef, panTo, setMap };
4967
- };
4968
- const useHeycarMap = () => {
4969
- const { supplier } = useMapSupplier();
4970
- return supplier === "gmap" ? useHeycarGamp() : useHeycarAmap();
4971
- };
4972
- const DRAGEND_DETECTING_ANIMATION_DELAY = 50;
4973
- const useAmapDrag = (props) => {
4974
- const { mapRef, onChange } = props;
4975
- const centerRef = Vue.ref([0, 0]);
4976
- const isDragging = Vue.ref(false);
4977
- const isDragEndWaitingMovingEndRef = Vue.ref(false);
4978
- let isZoom = false;
4979
- let zoomStartCenter = void 0;
4980
- let watchId = void 0;
4981
- const emitDragStart = () => {
4982
- pipeAsync(() => {
4983
- isDragging.value = true;
4984
- })();
4985
- };
4986
- const handleZoomStart = () => {
4987
- var _a;
4988
- isZoom = true;
4989
- zoomStartCenter = (_a = mapRef.value) == null ? void 0 : _a.getCenter().toJSON();
4990
- };
4991
- const handleChange = (value) => {
4992
- if (isZoom) {
4993
- isZoom = false;
4994
- if (isPointEqual(value, zoomStartCenter))
4995
- return;
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}`);
4996
5305
  }
4997
- onChange == null ? void 0 : onChange(value);
4998
- };
4999
- const handleDragEndWithAnimationEnd = (target) => {
5000
- var _a;
5001
- isDragEndWaitingMovingEndRef.value = false;
5002
- isDragging.value = false;
5003
- const { lng, lat } = target.getCenter();
5004
- spaceLog("onDragEndWithAnimationEnd", "[lng, lat] = ", [lng, lat]);
5005
- centerRef.value = [lng, lat];
5006
- (_a = pipeAsync(handleChange)) == null ? void 0 : _a([lng, lat]);
5007
- };
5008
- const emitDragEnd = (_, { target }) => {
5009
- const { lng: baseLng, lat: baseLat } = target.getCenter();
5010
- isDragEndWaitingMovingEndRef.value = true;
5011
- if (watchId)
5012
- clearTimeout(watchId);
5013
- watchId = setTimeout(() => {
5014
- watchId = void 0;
5015
- const { lng, lat } = target.getCenter();
5016
- if (!isDragEndWaitingMovingEndRef.value)
5017
- return;
5018
- if (baseLng !== lng || baseLat !== lat)
5019
- return;
5020
- handleDragEndWithAnimationEnd(target);
5021
- }, DRAGEND_DETECTING_ANIMATION_DELAY);
5022
- };
5023
- const handleMoveEnd = (_, { target }) => {
5024
- if (!isDragEndWaitingMovingEndRef.value)
5025
- return;
5026
- handleDragEndWithAnimationEnd(target);
5027
- };
5028
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomStart, [
5029
- "onZoomStart"
5030
- ]);
5031
- watchPostEffectForAMapEvent(mapRef, {}, emitDragStart, [
5032
- "onDragStart"
5033
- ]);
5034
- watchPostEffectForAMapEvent(mapRef, {}, emitDragEnd, [
5035
- "onDragEnd"
5036
- ]);
5037
- watchPostEffectForAMapEvent(mapRef, {}, handleMoveEnd, [
5038
- "onMoveend"
5039
- ]);
5040
- return { centerRef, isDragging };
5041
- };
5042
- const useGmapDrag = (props) => {
5043
- const { mapRef, onChange } = props;
5044
- const centerRef = Vue.ref([0, 0]);
5045
- const isDragging = Vue.ref(false);
5046
- const emitDragStart = () => {
5047
- pipeAsync(() => {
5048
- isDragging.value = true;
5049
- })();
5050
- };
5051
- const emitDragEnd = async () => {
5052
- var _a, _b;
5053
- isDragging.value = false;
5054
- const center = (_a = mapRef.value) == null ? void 0 : _a.getCenter();
5055
- const lng = center == null ? void 0 : center.lng();
5056
- const lat = center == null ? void 0 : center.lat();
5057
- centerRef.value = [lng, lat];
5058
- (_b = pipeAsync(onChange)) == null ? void 0 : _b([lng, lat]);
5059
- };
5060
- watchPostEffectForGMapEvent(mapRef, {}, emitDragStart, [
5061
- "onDragStart"
5062
- ]);
5063
- watchPostEffectForGMapEvent(mapRef, {}, emitDragEnd, [
5064
- "onDragEnd"
5065
- ]);
5066
- return { centerRef, isDragging };
5067
- };
5068
- const useMapDrag = (props) => {
5069
- const { supplier } = useMapSupplier();
5070
- return supplier === "gmap" ? useGmapDrag(props) : useAmapDrag(props);
5071
- };
5072
- const useAmapGeometry = () => {
5073
- const payload = useMapSupplier();
5074
- const apiMapDistance = (from, to) => {
5075
- if (payload.status !== Status.SUCCESS)
5076
- return void 0;
5077
- return AMap.GeometryUtil.distance(from, to);
5078
- };
5079
- const apiMapDistanceToLine = (from, line) => {
5080
- if (payload.status !== Status.SUCCESS)
5081
- return void 0;
5082
- return AMap.GeometryUtil.distanceToLine(from, line);
5083
- };
5084
- const apiMapDistanceOfLine = (line) => {
5085
- if (payload.status !== Status.SUCCESS)
5086
- return void 0;
5087
- return AMap.GeometryUtil.distanceOfLine(line);
5088
- };
5089
- const apiMapIsPointInRing = (point, path) => {
5090
- if (payload.status !== Status.SUCCESS)
5091
- return void 0;
5092
- return AMap.GeometryUtil.isPointInRing(point, path);
5093
- };
5094
- return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
5095
- };
5096
- const useGmapGeometry = () => {
5097
- const payload = useMapSupplier();
5098
- const apiMapDistance = (from, to) => {
5099
- if (payload.status !== Status.SUCCESS)
5100
- return void 0;
5101
- return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
5102
- };
5103
- const apiMapDistanceToLine = (from, line) => {
5104
- if (payload.status !== Status.SUCCESS)
5105
- return void 0;
5106
- return 0;
5107
- };
5108
- const apiMapDistanceOfLine = (line) => {
5109
- if (payload.status !== Status.SUCCESS)
5110
- return void 0;
5111
- return google.maps.geometry.spherical.computeLength(line.map(vec2lnglat));
5112
- };
5113
- const apiMapIsPointInRing = (point, path) => {
5114
- if (payload.status !== Status.SUCCESS)
5115
- return void 0;
5116
- const polygon = new google.maps.Polygon({ paths: path.map(vec2lnglat) });
5117
- return google.maps.geometry.poly.containsLocation(vec2lnglat(point), polygon);
5118
- };
5119
- return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
5120
- };
5121
- const useMapGeometry = () => {
5122
- const { supplier } = useMapSupplier();
5123
- return supplier === "gmap" ? useGmapGeometry() : useAmapGeometry();
5124
- };
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
+ });
5125
5327
  const chinaBounds = [
5126
5328
  [
5127
5329
  108.03446,
@@ -6590,26 +6792,360 @@ const chinaBounds = [
6590
6792
  ];
6591
6793
  const useAmapInChina = () => {
6592
6794
  const payload = useMapSupplier();
6593
- 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) => {
6594
7100
  if (payload.status !== Status.SUCCESS)
6595
- return false;
6596
- return AMap.GeometryUtil.isPointInRing(point, chinaBounds);
7101
+ return void 0;
7102
+ return AMap.GeometryUtil.distance(from, to);
6597
7103
  };
6598
- return { inChina };
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 };
6599
7120
  };
6600
- const useGmapInChina = () => {
7121
+ const useGmapGeometry = () => {
6601
7122
  const payload = useMapSupplier();
6602
- const inChina = (point) => {
7123
+ const apiMapDistance = (from, to) => {
6603
7124
  if (payload.status !== Status.SUCCESS)
6604
- return false;
6605
- const chinaPolygon = new google.maps.Polygon({ paths: chinaBounds });
6606
- return google.maps.geometry.poly.containsLocation(vec2lnglat(point), chinaPolygon);
7125
+ return void 0;
7126
+ return google.maps.geometry.spherical.computeDistanceBetween(vec2lnglat(from), vec2lnglat(to));
6607
7127
  };
6608
- return { inChina };
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 };
6609
7145
  };
6610
- const useMapInChina = () => {
7146
+ const useMapGeometry = () => {
6611
7147
  const { supplier } = useMapSupplier();
6612
- return supplier === "gmap" ? useGmapInChina() : useAmapInChina();
7148
+ return supplier === "gmap" ? useGmapGeometry() : useAmapGeometry();
6613
7149
  };
6614
7150
  const useUpdate = () => {
6615
7151
  const idx = Vue.ref(0);
@@ -7768,7 +8304,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
7768
8304
  });
7769
8305
  };
7770
8306
  const defaultCenterPlacePromise = new Promise((resolve) => {
7771
- getDefaultCenterPlace().then(resolve).catch(() => resolve(void 0));
8307
+ pipeTimeout(getDefaultCenterPlace, void 0, GET_DEFAULT_CENTER_PLACE_TIMEOUT)().then(resolve).catch(() => resolve(void 0));
7772
8308
  });
7773
8309
  const {
7774
8310
  orientation