@heycar/heycars-map 2.0.0-switchMap1 → 2.0.0-switchMap10

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.
Files changed (122) hide show
  1. package/README.md +43 -29
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/v2/App.js +5 -3
  5. package/dist/v2/Demo/DemoBusinessQuoting.js +3 -2
  6. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +1 -1
  7. package/dist/v2/api/cdn.d.ts +1 -0
  8. package/dist/v2/api/cdn.js +2 -0
  9. package/dist/v2/api/googleSnapRoad.js +7 -2
  10. package/dist/v2/api/pingConnection.d.ts +9 -0
  11. package/dist/v2/api/pingConnection.js +111 -0
  12. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  13. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  14. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +4 -3
  15. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +3 -3
  16. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +2 -2
  17. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +22 -13
  18. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  19. package/dist/v2/chunks/{BusinessRecomendPlaceMap.5be4fdcf.js → BusinessRecomendPlaceMap.b4d45108.js} +30 -18
  20. package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.492acbc2.js} +30 -2
  21. package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
  22. package/dist/v2/components/Loading/Loading.d.ts +6 -0
  23. package/dist/v2/components/Loading/Loading.js +4 -2
  24. package/dist/v2/components/Loading/index.js +3 -2
  25. package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
  26. package/dist/v2/components/MapProvider/MapProvider.js +23 -13
  27. package/dist/v2/css/Loading-49e58ced.css +46 -0
  28. package/dist/v2/hooks/useDrivingRoute.js +4 -0
  29. package/dist/v2/hooks/useMapGCJ02.js +4 -37
  30. package/dist/v2/hooks/useMapGeometry.d.ts +1 -3
  31. package/dist/v2/hooks/useMapGeometry.js +4 -4
  32. package/dist/v2/hooks/useMapGraspRoad.js +1 -2
  33. package/dist/v2/hooks/useMapInChina.d.ts +3 -15
  34. package/dist/v2/hooks/useMapInChina.js +11 -16
  35. package/dist/v2/hooks/useMapLoader.d.ts +13 -7
  36. package/dist/v2/hooks/useMapLoader.js +144 -82
  37. package/dist/v2/hooks/useMapPlace.d.ts +1 -0
  38. package/dist/v2/hooks/useMapPlace.js +52 -44
  39. package/dist/v2/hooks/useMapRecomendPlace.d.ts +1 -0
  40. package/dist/v2/hooks/useMapRecomendPlace.js +75 -67
  41. package/dist/v2/hooks/useMapSupplier.d.ts +8 -0
  42. package/dist/v2/hooks/useMapSupplier.js +17 -0
  43. package/dist/v2/hooks/usePingConnection.d.ts +10 -0
  44. package/dist/v2/hooks/usePingConnection.js +26 -0
  45. package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +2 -0
  46. package/dist/v2/hooks-business/useBusinessQuotingMap.js +7 -2
  47. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  48. package/dist/v2/index.js +1 -1
  49. package/dist/v2/types/global.d.ts +3 -0
  50. package/dist/v2/types/interface.d.ts +1 -1
  51. package/dist/v2/utils/ManualAbortError.d.ts +3 -0
  52. package/dist/v2/utils/ManualAbortError.js +14 -0
  53. package/dist/v2/utils/helper.d.ts +2 -0
  54. package/dist/v2/utils/helper.js +29 -0
  55. package/dist/v2/utils/log.js +1 -1
  56. package/dist/v2/utils/patchGoogleMapLoader.d.ts +2 -0
  57. package/dist/v2/utils/patchGoogleMapLoader.js +64 -0
  58. package/dist/v3/App.js +5 -3
  59. package/dist/v3/Demo/DemoBusinessQuoting.js +4 -3
  60. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
  61. package/dist/v3/api/cdn.d.ts +1 -0
  62. package/dist/v3/api/cdn.js +2 -0
  63. package/dist/v3/api/googleSnapRoad.js +7 -2
  64. package/dist/v3/api/pingConnection.d.ts +9 -0
  65. package/dist/v3/api/pingConnection.js +111 -0
  66. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +5 -2
  67. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -2
  68. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +4 -3
  69. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +3 -3
  70. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +2 -2
  71. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +22 -13
  72. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +12 -5
  73. package/dist/v3/chunks/{BusinessRecomendPlaceMap.39888296.js → BusinessRecomendPlaceMap.6ba5dbb1.js} +30 -18
  74. package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.21d8e759.js} +26 -2
  75. package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
  76. package/dist/v3/components/Loading/Loading.d.ts +8 -0
  77. package/dist/v3/components/Loading/Loading.js +4 -2
  78. package/dist/v3/components/Loading/index.js +3 -2
  79. package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
  80. package/dist/v3/components/MapProvider/MapProvider.js +21 -13
  81. package/dist/v3/css/Loading-49e58ced.css +46 -0
  82. package/dist/v3/hooks/useDrivingRoute.js +4 -0
  83. package/dist/v3/hooks/useMapGCJ02.js +4 -37
  84. package/dist/v3/hooks/useMapGeometry.d.ts +1 -3
  85. package/dist/v3/hooks/useMapGeometry.js +4 -4
  86. package/dist/v3/hooks/useMapGraspRoad.js +1 -2
  87. package/dist/v3/hooks/useMapInChina.d.ts +3 -15
  88. package/dist/v3/hooks/useMapInChina.js +11 -16
  89. package/dist/v3/hooks/useMapLoader.d.ts +13 -7
  90. package/dist/v3/hooks/useMapLoader.js +144 -82
  91. package/dist/v3/hooks/useMapPlace.d.ts +1 -0
  92. package/dist/v3/hooks/useMapPlace.js +52 -44
  93. package/dist/v3/hooks/useMapRecomendPlace.d.ts +1 -0
  94. package/dist/v3/hooks/useMapRecomendPlace.js +75 -67
  95. package/dist/v3/hooks/useMapSupplier.d.ts +8 -0
  96. package/dist/v3/hooks/useMapSupplier.js +17 -0
  97. package/dist/v3/hooks/usePingConnection.d.ts +10 -0
  98. package/dist/v3/hooks/usePingConnection.js +26 -0
  99. package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +2 -0
  100. package/dist/v3/hooks-business/useBusinessQuotingMap.js +7 -2
  101. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  102. package/dist/v3/index.js +1 -1
  103. package/dist/v3/types/global.d.ts +3 -0
  104. package/dist/v3/types/interface.d.ts +1 -1
  105. package/dist/v3/utils/ManualAbortError.d.ts +3 -0
  106. package/dist/v3/utils/ManualAbortError.js +14 -0
  107. package/dist/v3/utils/helper.d.ts +2 -0
  108. package/dist/v3/utils/helper.js +29 -0
  109. package/dist/v3/utils/log.js +1 -1
  110. package/dist/v3/utils/patchGoogleMapLoader.d.ts +2 -0
  111. package/dist/v3/utils/patchGoogleMapLoader.js +64 -0
  112. package/package.json +2 -2
  113. package/dist/v2/api/googleConnection.d.ts +0 -5
  114. package/dist/v2/api/googleConnection.js +0 -51
  115. package/dist/v2/css/Loading-523061b9.css +0 -9
  116. package/dist/v2/hooks/useGoogleConnection.d.ts +0 -7
  117. package/dist/v2/hooks/useGoogleConnection.js +0 -15
  118. package/dist/v3/api/googleConnection.d.ts +0 -5
  119. package/dist/v3/api/googleConnection.js +0 -51
  120. package/dist/v3/css/Loading-523061b9.css +0 -9
  121. package/dist/v3/hooks/useGoogleConnection.d.ts +0 -7
  122. package/dist/v3/hooks/useGoogleConnection.js +0 -15
@@ -1,3 +1,11 @@
1
1
  export declare const Loading: import("vue").DefineComponent<import("vue").ComponentObjectPropsOptions<unknown>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<unknown, Required<unknown>>, never, import("vue").PublicProps, unknown, unknown, import("vue").SlotsType<{} & {
2
2
  default?: import("../../demi-polyfill").Slot | undefined;
3
3
  }>>;
4
+ interface LoadFailedProps {
5
+ title?: string;
6
+ description?: string;
7
+ }
8
+ export declare const LoadFailed: import("vue").DefineComponent<import("vue").ComponentObjectPropsOptions<LoadFailedProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<LoadFailedProps, Required<LoadFailedProps>>, never, import("vue").PublicProps, LoadFailedProps, LoadFailedProps, import("vue").SlotsType<{} & {
9
+ default?: import("../../demi-polyfill").Slot | undefined;
10
+ }>>;
11
+ export {};
@@ -1,7 +1,9 @@
1
1
  import "vue";
2
- import { L } from "../../chunks/Loading.a8e2f26a.js";
2
+ import "../../api/cdn.js";
3
+ import { L, a } from "../../chunks/Loading.21d8e759.js";
3
4
  import "../../business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
4
5
  import "../../types/helper.js";
5
6
  export {
6
- L as Loading
7
+ L as LoadFailed,
8
+ a as Loading
7
9
  };
@@ -1,4 +1,5 @@
1
- import { L } from "../../chunks/Loading.a8e2f26a.js";
1
+ import { L, a } from "../../chunks/Loading.21d8e759.js";
2
2
  export {
3
- L as Loading
3
+ L as LoadFailed,
4
+ a as Loading
4
5
  };
@@ -1,12 +1,15 @@
1
1
  /// <reference types="google.maps" />
2
2
  import type { VueNode } from "../../demi-polyfill";
3
3
  import type { SetMap } from "../../hooks/useHeycarMap";
4
- import { type GmapLoaderProps, type UseMapLoaderProps } from "../../hooks/useMapLoader";
4
+ import { Status, type GmapLoaderProps, type UseMapLoaderProps } from "../../hooks/useMapLoader";
5
5
  import { type MapSupplierPayolad } from "../../hooks/useMapSupplier";
6
6
  import type { AmapMap } from "../../types/interface";
7
7
  import { type AmapProps } from "../Amap";
8
- export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId">;
9
- export declare const MapProvider: import("vue").DefineComponent<import("vue").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "change", import("vue").PublicProps, MapProviderProps, MapProviderProps, import("vue").SlotsType<{} & {
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "renderLoadFailedTitle" | "renderLoadFailedDescription">;
9
+ export declare const MapProvider: import("vue").DefineComponent<import("vue").ComponentObjectPropsOptions<MapProviderProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<MapProviderProps, Required<MapProviderProps>>, "success" | "fail", import("vue").PublicProps, MapProviderProps, MapProviderProps, import("vue").SlotsType<{
10
+ renderLoadFailedTitle?: ((status: Status) => string | undefined) | undefined;
11
+ renderLoadFailedDescription?: ((status: Status) => string | undefined) | undefined;
12
+ } & {
10
13
  default?: import("../../demi-polyfill").Slot | undefined;
11
14
  }>>;
12
15
  export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
@@ -1,6 +1,6 @@
1
1
  import "../../css/MapProvider-156bfd53.css";
2
2
  import { createVNode, isVNode } from "vue";
3
- import { L as Loading, i as imgGrid } from "../../chunks/Loading.a8e2f26a.js";
3
+ import { L as LoadFailed, a as Loading, i as imgGrid } from "../../chunks/Loading.21d8e759.js";
4
4
  import { useMapLoader, Status } from "../../hooks/useMapLoader.js";
5
5
  import { provideMapSupplier, useMapSupplier } from "../../hooks/useMapSupplier.js";
6
6
  import { defineLagecySetup } from "../../types/helper.js";
@@ -29,6 +29,8 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
29
29
  get(target, name, receiver) {
30
30
  if (name === "status")
31
31
  return payload.statusRef.value;
32
+ if (name === "pingStatus")
33
+ return payload.pingStatusRef.value;
32
34
  if (name === "readyPromise")
33
35
  return payload.readyPromise;
34
36
  return Reflect.get(target, name, receiver);
@@ -39,7 +41,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
39
41
  var _a;
40
42
  return createVNode("div", null, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
41
43
  };
42
- }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language"]);
44
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "renderLoadFailedTitle", "renderLoadFailedDescription"]);
43
45
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
44
46
  slots,
45
47
  emit,
@@ -67,13 +69,14 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
67
69
  const handleResize = () => emit("resize");
68
70
  loadTraditionalChineseConvertOnce(payload.language === "zh-TW");
69
71
  return () => {
70
- var _a, _b, _c, _d, _e, _f;
72
+ var _a, _b, _c, _d, _e, _f, _g, _h;
71
73
  const {
72
74
  supplier,
73
75
  gmapId,
74
76
  gmapRasterId,
75
77
  language = "zh",
76
- status
78
+ status,
79
+ pingStatus
77
80
  } = payload;
78
81
  const {
79
82
  mapRef: setMap,
@@ -82,16 +85,21 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
82
85
  touchEnable = true,
83
86
  touchZoomCenter
84
87
  } = props;
85
- if (status === Status.LOADING) {
86
- const node = (_a = slots.loading) == null ? void 0 : _a.call(slots);
87
- return node ? createVNode("div", null, [node]) : createVNode(Loading, null, null);
88
+ if (status === Status.FAILURE || pingStatus === "unconnected") {
89
+ const node = (_a = slots.fallback) == null ? void 0 : _a.call(slots);
90
+ const title = (_b = payload.renderLoadFailedTitle) == null ? void 0 : _b.call(payload, status);
91
+ const description = (_c = payload.renderLoadFailedDescription) == null ? void 0 : _c.call(payload, status);
92
+ return node ? createVNode("div", null, [node]) : createVNode(LoadFailed, {
93
+ "title": title,
94
+ "description": description
95
+ }, null);
88
96
  }
89
- if (status === Status.FAILURE) {
90
- const node = (_b = slots.fallback) == null ? void 0 : _b.call(slots);
97
+ if (status === Status.LOADING || status === Status.SUCCESS && pingStatus === "pending") {
98
+ const node = (_d = slots.loading) == null ? void 0 : _d.call(slots);
91
99
  return node ? createVNode("div", null, [node]) : createVNode(Loading, null, null);
92
100
  }
93
- const children = (_c = slots.default) == null ? void 0 : _c.call(slots);
94
- const outArea = (_d = slots.outerArea) == null ? void 0 : _d.call(slots);
101
+ const children = (_e = slots.default) == null ? void 0 : _e.call(slots);
102
+ const outArea = (_f = slots.outerArea) == null ? void 0 : _f.call(slots);
95
103
  const mapId = patchGmapIdForAlipayCompatible({
96
104
  gmapId,
97
105
  gmapRasterId,
@@ -101,7 +109,7 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
101
109
  switch (supplier) {
102
110
  case "gmap":
103
111
  return createVNode("div", {
104
- "class": `${heycarMap} ${(_e = attrs.class) != null ? _e : ""}`,
112
+ "class": `${heycarMap} ${(_g = attrs.class) != null ? _g : ""}`,
105
113
  "lang": language,
106
114
  "style": attrs.style
107
115
  }, [createVNode(Gmap, {
@@ -126,7 +134,7 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
126
134
  }, null), outArea]);
127
135
  default:
128
136
  return createVNode("div", {
129
- "class": `${heycarMap} ${(_f = attrs.class) != null ? _f : ""}`,
137
+ "class": `${heycarMap} ${(_h = attrs.class) != null ? _h : ""}`,
130
138
  "lang": language,
131
139
  "style": attrs.style
132
140
  }, [createVNode(Amap, {
@@ -0,0 +1,46 @@
1
+ ._17ify490 {
2
+ position: relative;
3
+ background-color: #EDF1F5;
4
+ }
5
+ ._17ify491 {
6
+ position: absolute;
7
+ width: 100%;
8
+ height: 100%;
9
+ object-fit: cover;
10
+ }
11
+ ._17ify492 {
12
+ position: absolute;
13
+ margin: auto;
14
+ top: -5vh;
15
+ left: 0;
16
+ right: 0;
17
+ bottom: 0;
18
+ width: fit-content;
19
+ height: fit-content;
20
+ display: flex;
21
+ flex-direction: column;
22
+ align-items: center;
23
+ }
24
+ ._17ify493 {
25
+ width: 40.8vw;
26
+ height: 24.53vw;
27
+ }
28
+ ._17ify494 {
29
+ margin-top: 1.6vw;
30
+ }
31
+ ._17ify495 {
32
+ font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
33
+ font-weight: 500;
34
+ font-size: 4vw;
35
+ color: #1E1E1E;
36
+ line-height: 6.4vw;
37
+ }
38
+ ._17ify496 {
39
+ font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
40
+ font-weight: 400;
41
+ font-size: 3.73vw;
42
+ color: #999BA1;
43
+ line-height: 6.4vw;
44
+ white-space: pre-line;
45
+ text-align: center;
46
+ }
@@ -23,6 +23,8 @@ const useADrivingRoute = (props) => {
23
23
  const drivingResult = result;
24
24
  const routeSteps = [];
25
25
  const firstRoute = drivingResult.routes[0];
26
+ if (!firstRoute)
27
+ return resolve({ path: [], distance: 0, duration: 0, steps: [] });
26
28
  for (const step of firstRoute.steps) {
27
29
  const basicStep = step;
28
30
  const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
@@ -83,6 +85,8 @@ const useGDrivingRoute = (props) => {
83
85
  let duration = 0;
84
86
  const routeSteps = [];
85
87
  const firstRoute = result.routes[0];
88
+ if (!firstRoute)
89
+ return resolve({ path: [], distance: 0, duration: 0, steps: [] });
86
90
  for (const leg of firstRoute.legs) {
87
91
  distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
88
92
  duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
@@ -1,6 +1,4 @@
1
- import { AMAP_TO_GCJ02_TIMEOUT } from "../api/contants.js";
2
- import { lnglat2point } from "../utils/transform.js";
3
- import { useMapInChina } from "./useMapInChina.js";
1
+ import { inChina, inHongkong, inMacau } from "./useMapInChina.js";
4
2
  import { useMapSupplier } from "./useMapSupplier.js";
5
3
  /**
6
4
  * @preserve
@@ -514,8 +512,6 @@ const exported = Object.assign(Object.assign({}, CRSTypes), {
514
512
  transform
515
513
  });
516
514
  const useAmapGCJ02 = () => {
517
- const { readyPromise } = useMapSupplier();
518
- const { inChina } = useMapInChina();
519
515
  const toCoordinateType = (p) => {
520
516
  return inChina(p) ? "gcj02" : "wgs84";
521
517
  };
@@ -532,42 +528,15 @@ const useAmapGCJ02 = () => {
532
528
  }
533
529
  };
534
530
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
535
- async function toGcj02Points(points) {
536
- await readyPromise;
537
- return new Promise((resolve) => {
538
- let isHandled = false;
539
- AMap.convertFrom(
540
- [...points],
541
- "gps",
542
- (_, result) => {
543
- if (isHandled)
544
- return;
545
- isHandled = true;
546
- if (result.info === "ok") {
547
- resolve(result.locations.map(lnglat2point));
548
- } else {
549
- console.warn("警告: 高德坐标转换请求失败,启用本地转换");
550
- resolve(toLocalGcj02Points(points));
551
- }
552
- }
553
- );
554
- setTimeout(() => {
555
- if (isHandled)
556
- return;
557
- isHandled = true;
558
- console.warn("警告: 高德坐标转换请求超时,启用本地转换");
559
- resolve(toLocalGcj02Points(points));
560
- }, AMAP_TO_GCJ02_TIMEOUT);
561
- });
562
- }
531
+ const toGcj02Points = async (points) => {
532
+ return toLocalGcj02Points(points);
533
+ };
563
534
  function toGcj02(point) {
564
535
  return toGcj02Points([point]).then(([result]) => result);
565
536
  }
566
537
  return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
567
538
  };
568
539
  const useGmapGCJ02 = () => {
569
- const { readyPromise } = useMapSupplier();
570
- const { inChina, inHongkong, inMacau } = useMapInChina();
571
540
  const toCoordinateType = (p) => {
572
541
  return inChina(p) && !inHongkong(p) && !inMacau(p) ? "gcj02" : "wgs84";
573
542
  };
@@ -585,11 +554,9 @@ const useGmapGCJ02 = () => {
585
554
  };
586
555
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
587
556
  const toGcj02 = async (point) => {
588
- await readyPromise;
589
557
  return toLocalGcj02Points([point])[0];
590
558
  };
591
559
  const toGcj02Points = async (points) => {
592
- await readyPromise;
593
560
  return toLocalGcj02Points(points);
594
561
  };
595
562
  return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
@@ -1,19 +1,17 @@
1
1
  import type { Point } from "../types/interface";
2
+ export declare const apiLocalIsPointInRing: (point: Point, path: Point[]) => boolean;
2
3
  export declare const useAmapGeometry: () => {
3
4
  apiMapDistance: (from: Point, to: Point) => number | undefined;
4
5
  apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
5
- apiMapIsPointInRing: (point: Point, path: Point[]) => boolean;
6
6
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
7
7
  };
8
8
  export declare const useGmapGeometry: () => {
9
9
  apiMapDistance: (from: Point, to: Point) => number | undefined;
10
10
  apiMapDistanceToLine: (from: Point, line: Point[]) => 0 | undefined;
11
- apiMapIsPointInRing: (point: Point, path: Point[]) => boolean;
12
11
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
13
12
  };
14
13
  export declare const useMapGeometry: () => {
15
14
  apiMapDistance: (from: Point, to: Point) => number | undefined;
16
15
  apiMapDistanceToLine: (from: Point, line: Point[]) => number | undefined;
17
- apiMapIsPointInRing: (point: Point, path: Point[]) => boolean;
18
16
  apiMapDistanceOfLine: (line: Point[]) => number | undefined;
19
17
  };
@@ -2,6 +2,7 @@ import { pointInPolygon } from "../utils/geometryPolygon.js";
2
2
  import { vec2lnglat } from "../utils/transform.js";
3
3
  import { Status } from "./useMapLoader.js";
4
4
  import { useMapSupplier } from "./useMapSupplier.js";
5
+ const apiLocalIsPointInRing = (point, path) => pointInPolygon(point, path) >= 0;
5
6
  const useAmapGeometry = () => {
6
7
  const payload = useMapSupplier();
7
8
  const apiMapDistance = (from, to) => {
@@ -19,8 +20,7 @@ const useAmapGeometry = () => {
19
20
  return void 0;
20
21
  return AMap.GeometryUtil.distanceOfLine(line);
21
22
  };
22
- const apiMapIsPointInRing = (point, path) => pointInPolygon(point, path) >= 0;
23
- return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
23
+ return { apiMapDistance, apiMapDistanceToLine, apiMapDistanceOfLine };
24
24
  };
25
25
  const useGmapGeometry = () => {
26
26
  const payload = useMapSupplier();
@@ -39,14 +39,14 @@ const useGmapGeometry = () => {
39
39
  return void 0;
40
40
  return google.maps.geometry.spherical.computeLength(line.map(vec2lnglat));
41
41
  };
42
- const apiMapIsPointInRing = (point, path) => pointInPolygon(point, path) >= 0;
43
- return { apiMapDistance, apiMapDistanceToLine, apiMapIsPointInRing, apiMapDistanceOfLine };
42
+ return { apiMapDistance, apiMapDistanceToLine, apiMapDistanceOfLine };
44
43
  };
45
44
  const useMapGeometry = () => {
46
45
  const { supplier } = useMapSupplier();
47
46
  return supplier === "gmap" ? useGmapGeometry() : useAmapGeometry();
48
47
  };
49
48
  export {
49
+ apiLocalIsPointInRing,
50
50
  useAmapGeometry,
51
51
  useGmapGeometry,
52
52
  useMapGeometry
@@ -3,7 +3,7 @@ import { apiGoogleSnapRoad } from "../api/googleSnapRoad.js";
3
3
  import { watchEffectForDeepOption } from "../utils/compare.js";
4
4
  import { lnglat2point, trackPoints2amapGraspRoadPoints } from "../utils/transform.js";
5
5
  import { useMapAngle } from "./useMapAngle.js";
6
- import { useMapInChina } from "./useMapInChina.js";
6
+ import { inChina } from "./useMapInChina.js";
7
7
  import { useMapSupplier } from "./useMapSupplier.js";
8
8
  const GRASP_ROAD_INPUT_MIN_AMOUNT = 2;
9
9
  const GRASP_ROAD_INPUT_MAX_AMOUNT = 500;
@@ -12,7 +12,6 @@ const useAmapGraspRoad = (props) => {
12
12
  const pathRef = ref([]);
13
13
  const angleRef = ref(0);
14
14
  const { apiMapComputeHeading } = useMapAngle();
15
- const { inChina } = useMapInChina();
16
15
  const apiMapToGraspRoadPath = (tracks) => {
17
16
  return new Promise((resolve) => {
18
17
  var _a, _b, _c;
@@ -1,16 +1,4 @@
1
1
  import { type Point } from "../types/interface";
2
- export declare const useMapInChina: () => {
3
- inChina: (point: Point) => boolean;
4
- inHongkong: (point: Point) => boolean;
5
- inMacau: (point: Point) => boolean;
6
- };
7
- export declare const useAmapInChina: () => {
8
- inChina: (point: Point) => boolean;
9
- inHongkong: (point: Point) => boolean;
10
- inMacau: (point: Point) => boolean;
11
- };
12
- export declare const useGmapInChina: () => {
13
- inChina: (point: Point) => boolean;
14
- inHongkong: (point: Point) => boolean;
15
- inMacau: (point: Point) => boolean;
16
- };
2
+ export declare const inChina: (point: Point) => boolean;
3
+ export declare const inHongkong: (point: Point) => boolean;
4
+ export declare const inMacau: (point: Point) => boolean;
@@ -2593,22 +2593,17 @@ const macauBounds = [
2593
2593
  22.19885
2594
2594
  ]
2595
2595
  ];
2596
- const useMapInChina = () => {
2597
- const inChina = (point) => {
2598
- return pointInPolygon(point, chinaBounds) >= 0;
2599
- };
2600
- const inHongkong = (point) => {
2601
- return pointInPolygon(point, hongkongBounds) >= 0;
2602
- };
2603
- const inMacau = (point) => {
2604
- return pointInPolygon(point, macauBounds) >= 0;
2605
- };
2606
- return { inChina, inHongkong, inMacau };
2596
+ const inChina = (point) => {
2597
+ return pointInPolygon(point, chinaBounds) >= 0;
2598
+ };
2599
+ const inHongkong = (point) => {
2600
+ return pointInPolygon(point, hongkongBounds) >= 0;
2601
+ };
2602
+ const inMacau = (point) => {
2603
+ return pointInPolygon(point, macauBounds) >= 0;
2607
2604
  };
2608
- const useAmapInChina = useMapInChina;
2609
- const useGmapInChina = useMapInChina;
2610
2605
  export {
2611
- useAmapInChina,
2612
- useGmapInChina,
2613
- useMapInChina
2606
+ inChina,
2607
+ inHongkong,
2608
+ inMacau
2614
2609
  };
@@ -2,7 +2,7 @@ import { load as loadAmap } from "@amap/amap-jsapi-loader";
2
2
  import { type LoaderOptions } from "@googlemaps/js-api-loader";
3
3
  import { type Ref } from "vue-demi";
4
4
  import type { VNodeChild } from "../demi-polyfill";
5
- import type { Language } from "../types/interface";
5
+ import type { ConnectionStatus, Language } from "../types/interface";
6
6
  export declare const DEFAULT_AMAP_PLUGINS: AmapLoaderProps["plugins"];
7
7
  export declare const DEFAULT_GMAP_LIBRARIES: LoaderOptions["libraries"];
8
8
  export declare enum Status {
@@ -19,7 +19,7 @@ declare global {
19
19
  };
20
20
  }
21
21
  }
22
- export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loading" | "onChange">, Omit<AMapLoaderOptions, "key" | "version" | "plugins"> {
22
+ export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loading" | "onSuccess" | "onFail">, Omit<AMapLoaderOptions, "key" | "version" | "plugins"> {
23
23
  apiKey: string;
24
24
  apiSecret?: string;
25
25
  apiServiceHost?: string;
@@ -29,6 +29,7 @@ export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loa
29
29
  }
30
30
  export declare const useAmapLoader: (props: AmapLoaderProps) => {
31
31
  statusRef: import("vue-demi").ShallowRef<Status>;
32
+ pingStatusRef: import("vue-demi").ShallowRef<ConnectionStatus>;
32
33
  readyPromise: Promise<undefined>;
33
34
  };
34
35
  export interface GmapLoaderProps extends LoaderOptions {
@@ -42,19 +43,23 @@ export interface GmapLoaderProps extends LoaderOptions {
42
43
  */
43
44
  fallback?: () => VNodeChild;
44
45
  /**
45
- * Callback prop used to access `@googlemaps/js-api-loader` and `Status`.
46
- *
47
- * Note: The callback be executed multiple times in the lifecycle of the component.
46
+ * 成功回调只会触发一次
48
47
  */
49
- onChange?: (status: Status) => void;
48
+ onSuccess?: () => void;
49
+ /**
50
+ * 失败回调可能会触发多次
51
+ */
52
+ onFail?: () => void;
50
53
  }
51
54
  export declare const useGmapLoader: (props: GmapLoaderProps) => {
52
55
  statusRef: import("vue-demi").ShallowRef<Status>;
56
+ pingStatusRef: import("vue-demi").ShallowRef<ConnectionStatus>;
53
57
  readyPromise: Promise<undefined>;
54
58
  };
55
59
  export type MapSupplier = "gmap" | "amap";
56
60
  export interface UseMapLoaderOutput {
57
61
  statusRef: Ref<Status>;
62
+ pingStatusRef: Ref<ConnectionStatus>;
58
63
  readyPromise: Promise<undefined>;
59
64
  }
60
65
  export interface UseMapLoaderProps {
@@ -64,7 +69,8 @@ export interface UseMapLoaderProps {
64
69
  amapServiceHost?: string;
65
70
  supplier: MapSupplier;
66
71
  language: Language;
67
- onChange?: (status: Status) => any;
72
+ onSuccess?: () => void;
73
+ onFail?: () => void;
68
74
  }
69
75
  export declare const useMapLoader: (props: UseMapLoaderProps) => UseMapLoaderOutput;
70
76
  export {};