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