@heycar/heycars-map 1.0.0-coordinate7 → 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 (192) hide show
  1. package/README.md +45 -52
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/v2/App.js +8 -4
  5. package/dist/v2/Demo/DemoBusinessQuoting.js +6 -12
  6. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +3 -8
  7. package/dist/v2/Demo/DemoBusinessReselectPlace.js +2 -7
  8. package/dist/v2/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
  9. package/dist/v2/Demo/DemoBusinessTaxiEnd.js +2 -18
  10. package/dist/v2/Demo/DemoBusinessTaxiService.d.ts +1 -2392
  11. package/dist/v2/Demo/DemoBusinessTaxiService.js +6 -19
  12. package/dist/v2/api/cdn.d.ts +1 -0
  13. package/dist/v2/api/cdn.js +2 -0
  14. package/dist/v2/api/googleSnapRoad.js +7 -2
  15. package/dist/v2/api/pingConnection.d.ts +9 -0
  16. package/dist/v2/api/pingConnection.js +111 -0
  17. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +5 -5
  18. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +46 -12
  19. package/dist/v2/business-components/BusinessQuotingMap/index.js +3 -2
  20. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -3
  21. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +7 -4
  22. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +4 -3
  23. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +3 -2
  24. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +60 -24
  25. package/dist/v2/business-components/BusinessReselectPlaceMap/index.js +3 -2
  26. package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +2 -3
  27. package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
  28. package/dist/v2/business-components/BusinessTaxiEndMap/index.js +3 -2
  29. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +5 -5
  30. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +52 -21
  31. package/dist/v2/business-components/BusinessTaxiServiceMap/index.js +3 -2
  32. package/dist/v2/chunks/{BusinessRecomendPlaceMap.87ea3b2f.js → BusinessRecomendPlaceMap.b4d45108.js} +65 -30
  33. package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.492acbc2.js} +30 -2
  34. package/dist/v2/components/AmapMarker/AmapMarker.js +2 -1
  35. package/dist/v2/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
  36. package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
  37. package/dist/v2/components/Loading/Loading.d.ts +6 -0
  38. package/dist/v2/components/Loading/Loading.js +4 -2
  39. package/dist/v2/components/Loading/index.js +3 -2
  40. package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
  41. package/dist/v2/components/MapProvider/MapProvider.js +24 -13
  42. package/dist/v2/css/Loading-49e58ced.css +46 -0
  43. package/dist/v2/demi-polyfill/demi-polyfill.d.ts +1 -0
  44. package/dist/v2/hooks/useDrivingRoute.js +4 -0
  45. package/dist/v2/hooks/useMapGCJ02.js +4 -37
  46. package/dist/v2/hooks/useMapGeometry.d.ts +1 -3
  47. package/dist/v2/hooks/useMapGeometry.js +4 -4
  48. package/dist/v2/hooks/useMapGraspRoad.js +1 -2
  49. package/dist/v2/hooks/useMapInChina.d.ts +3 -15
  50. package/dist/v2/hooks/useMapInChina.js +11 -16
  51. package/dist/v2/hooks/useMapLoader.d.ts +18 -10
  52. package/dist/v2/hooks/useMapLoader.js +159 -82
  53. package/dist/v2/hooks/useMapPlace.d.ts +1 -0
  54. package/dist/v2/hooks/useMapPlace.js +52 -44
  55. package/dist/v2/hooks/useMapRecomendPlace.d.ts +1 -0
  56. package/dist/v2/hooks/useMapRecomendPlace.js +75 -67
  57. package/dist/v2/hooks/useMapSupplier.d.ts +8 -0
  58. package/dist/v2/hooks/useMapSupplier.js +17 -0
  59. package/dist/v2/hooks/usePingConnection.d.ts +10 -0
  60. package/dist/v2/hooks/usePingConnection.js +26 -0
  61. package/dist/v2/hooks-business/useBusinessAlarm.d.ts +3 -0
  62. package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
  63. package/dist/v2/hooks-business/useBusinessQuotingMap.js +10 -10
  64. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
  65. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
  66. package/dist/v2/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
  67. package/dist/v2/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
  68. package/dist/v2/hooks-business/useBusinessTaxiServiceMap.js +5 -10
  69. package/dist/v2/index.js +1 -1
  70. package/dist/v2/types/global.d.ts +3 -0
  71. package/dist/v2/types/interface.d.ts +1 -1
  72. package/dist/v2/utils/ManualAbortError.d.ts +3 -0
  73. package/dist/v2/utils/ManualAbortError.js +14 -0
  74. package/dist/v2/utils/compare.d.ts +4 -0
  75. package/dist/v2/utils/compare.js +6 -0
  76. package/dist/v2/utils/helper.d.ts +6 -0
  77. package/dist/v2/utils/helper.js +43 -0
  78. package/dist/v2/utils/log.js +1 -1
  79. package/dist/v2/utils/patchGoogleMapLoader.d.ts +2 -0
  80. package/dist/v2/utils/patchGoogleMapLoader.js +64 -0
  81. package/dist/v3/App.js +8 -4
  82. package/dist/v3/Demo/DemoBusinessQuoting.js +7 -13
  83. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +3 -8
  84. package/dist/v3/Demo/DemoBusinessReselectPlace.js +2 -7
  85. package/dist/v3/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
  86. package/dist/v3/Demo/DemoBusinessTaxiEnd.js +3 -17
  87. package/dist/v3/Demo/DemoBusinessTaxiService.d.ts +1 -2392
  88. package/dist/v3/Demo/DemoBusinessTaxiService.js +6 -17
  89. package/dist/v3/api/cdn.d.ts +1 -0
  90. package/dist/v3/api/cdn.js +2 -0
  91. package/dist/v3/api/googleSnapRoad.js +7 -2
  92. package/dist/v3/api/pingConnection.d.ts +9 -0
  93. package/dist/v3/api/pingConnection.js +111 -0
  94. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +16 -7
  95. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +46 -12
  96. package/dist/v3/business-components/BusinessQuotingMap/index.js +3 -2
  97. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +10 -3
  98. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +7 -4
  99. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +4 -3
  100. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +10 -2
  101. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +60 -24
  102. package/dist/v3/business-components/BusinessReselectPlaceMap/index.js +3 -2
  103. package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
  104. package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
  105. package/dist/v3/business-components/BusinessTaxiEndMap/index.js +3 -2
  106. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +19 -7
  107. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +52 -21
  108. package/dist/v3/business-components/BusinessTaxiServiceMap/index.js +3 -2
  109. package/dist/v3/chunks/{BusinessRecomendPlaceMap.57b15c64.js → BusinessRecomendPlaceMap.6ba5dbb1.js} +65 -30
  110. package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.21d8e759.js} +26 -2
  111. package/dist/v3/components/AmapMarker/AmapMarker.js +2 -1
  112. package/dist/v3/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
  113. package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
  114. package/dist/v3/components/Loading/Loading.d.ts +8 -0
  115. package/dist/v3/components/Loading/Loading.js +4 -2
  116. package/dist/v3/components/Loading/index.js +3 -2
  117. package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
  118. package/dist/v3/components/MapProvider/MapProvider.js +22 -13
  119. package/dist/v3/css/Loading-49e58ced.css +46 -0
  120. package/dist/v3/demi-polyfill/demi-polyfill.d.ts +1 -0
  121. package/dist/v3/hooks/useDrivingRoute.js +4 -0
  122. package/dist/v3/hooks/useMapGCJ02.js +4 -37
  123. package/dist/v3/hooks/useMapGeometry.d.ts +1 -3
  124. package/dist/v3/hooks/useMapGeometry.js +4 -4
  125. package/dist/v3/hooks/useMapGraspRoad.js +1 -2
  126. package/dist/v3/hooks/useMapInChina.d.ts +3 -15
  127. package/dist/v3/hooks/useMapInChina.js +11 -16
  128. package/dist/v3/hooks/useMapLoader.d.ts +18 -10
  129. package/dist/v3/hooks/useMapLoader.js +159 -82
  130. package/dist/v3/hooks/useMapPlace.d.ts +1 -0
  131. package/dist/v3/hooks/useMapPlace.js +52 -44
  132. package/dist/v3/hooks/useMapRecomendPlace.d.ts +1 -0
  133. package/dist/v3/hooks/useMapRecomendPlace.js +75 -67
  134. package/dist/v3/hooks/useMapSupplier.d.ts +8 -0
  135. package/dist/v3/hooks/useMapSupplier.js +17 -0
  136. package/dist/v3/hooks/usePingConnection.d.ts +10 -0
  137. package/dist/v3/hooks/usePingConnection.js +26 -0
  138. package/dist/v3/hooks-business/useBusinessAlarm.d.ts +3 -0
  139. package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
  140. package/dist/v3/hooks-business/useBusinessQuotingMap.js +10 -10
  141. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
  142. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
  143. package/dist/v3/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
  144. package/dist/v3/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
  145. package/dist/v3/hooks-business/useBusinessTaxiServiceMap.js +5 -10
  146. package/dist/v3/index.js +1 -1
  147. package/dist/v3/types/global.d.ts +3 -0
  148. package/dist/v3/types/interface.d.ts +1 -1
  149. package/dist/v3/utils/ManualAbortError.d.ts +3 -0
  150. package/dist/v3/utils/ManualAbortError.js +14 -0
  151. package/dist/v3/utils/compare.d.ts +4 -0
  152. package/dist/v3/utils/compare.js +6 -0
  153. package/dist/v3/utils/helper.d.ts +6 -0
  154. package/dist/v3/utils/helper.js +43 -0
  155. package/dist/v3/utils/log.js +1 -1
  156. package/dist/v3/utils/patchGoogleMapLoader.d.ts +2 -0
  157. package/dist/v3/utils/patchGoogleMapLoader.js +64 -0
  158. package/package.json +2 -2
  159. package/dist/v2/Demo/Demo.d.ts +0 -3
  160. package/dist/v2/Demo/Demo.js +0 -1634
  161. package/dist/v2/api/googleConnection.d.ts +0 -5
  162. package/dist/v2/api/googleConnection.js +0 -51
  163. package/dist/v2/components/AmapLoader/AmapLoader.d.ts +0 -5
  164. package/dist/v2/components/AmapLoader/AmapLoader.js +0 -21
  165. package/dist/v2/components/AmapLoader/index.d.ts +0 -1
  166. package/dist/v2/components/AmapLoader/index.js +0 -4
  167. package/dist/v2/components/GmapLoader/GmapLoader.d.ts +0 -5
  168. package/dist/v2/components/GmapLoader/GmapLoader.js +0 -21
  169. package/dist/v2/components/GmapLoader/index.d.ts +0 -1
  170. package/dist/v2/components/GmapLoader/index.js +0 -4
  171. package/dist/v2/css/Loading-523061b9.css +0 -9
  172. package/dist/v2/hooks/useGoogleConnection.d.ts +0 -7
  173. package/dist/v2/hooks/useGoogleConnection.js +0 -15
  174. package/dist/v2/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
  175. package/dist/v2/hooks-business/useBusinessTaxiEndMap.js +0 -7
  176. package/dist/v3/Demo/Demo.d.ts +0 -9
  177. package/dist/v3/Demo/Demo.js +0 -1612
  178. package/dist/v3/api/googleConnection.d.ts +0 -5
  179. package/dist/v3/api/googleConnection.js +0 -51
  180. package/dist/v3/components/AmapLoader/AmapLoader.d.ts +0 -10
  181. package/dist/v3/components/AmapLoader/AmapLoader.js +0 -21
  182. package/dist/v3/components/AmapLoader/index.d.ts +0 -1
  183. package/dist/v3/components/AmapLoader/index.js +0 -4
  184. package/dist/v3/components/GmapLoader/GmapLoader.d.ts +0 -10
  185. package/dist/v3/components/GmapLoader/GmapLoader.js +0 -21
  186. package/dist/v3/components/GmapLoader/index.d.ts +0 -1
  187. package/dist/v3/components/GmapLoader/index.js +0 -4
  188. package/dist/v3/css/Loading-523061b9.css +0 -9
  189. package/dist/v3/hooks/useGoogleConnection.d.ts +0 -7
  190. package/dist/v3/hooks/useGoogleConnection.js +0 -15
  191. package/dist/v3/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
  192. package/dist/v3/hooks-business/useBusinessTaxiEndMap.js +0 -7
@@ -1,6 +1,6 @@
1
1
  import "../../css/MapProvider-156bfd53.css";
2
2
  import { h } from "vue";
3
- import { L as Loading, i as imgGrid } from "../../chunks/Loading.fc6e75d0.js";
3
+ import { L as LoadFailed, a as Loading, i as imgGrid } from "../../chunks/Loading.492acbc2.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";
@@ -21,16 +21,15 @@ if (detectWebGL() === WEBGL_STATUS.ENABLED) {
21
21
  const MapProvider = defineLagecySetup("MapProvider", function(props, {
22
22
  slots
23
23
  }) {
24
- const {
25
- statusRef,
26
- readyPromise
27
- } = useMapLoader(props);
24
+ const payload = useMapLoader(props);
28
25
  const context = new Proxy(props, {
29
26
  get(target, name, receiver) {
30
27
  if (name === "status")
31
- return statusRef.value;
28
+ return payload.statusRef.value;
29
+ if (name === "pingStatus")
30
+ return payload.pingStatusRef.value;
32
31
  if (name === "readyPromise")
33
- return readyPromise;
32
+ return payload.readyPromise;
34
33
  return Reflect.get(target, name, receiver);
35
34
  }
36
35
  });
@@ -39,7 +38,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
39
38
  var _a;
40
39
  return h("div", [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
41
40
  };
42
- }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language"]);
41
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "renderLoadFailedTitle", "renderLoadFailedDescription"]);
43
42
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
44
43
  slots,
45
44
  emit,
@@ -73,7 +72,8 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
73
72
  gmapId,
74
73
  gmapRasterId,
75
74
  language = "zh",
76
- status
75
+ status,
76
+ pingStatus
77
77
  } = payload;
78
78
  const {
79
79
  mapRef: setMap,
@@ -82,10 +82,21 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
82
82
  touchEnable = true,
83
83
  touchZoomCenter
84
84
  } = props;
85
- if (status === Status.LOADING)
86
- return (_b = (_a = slots.loading) == null ? void 0 : _a.call(slots)) != null ? _b : h(Loading);
87
- if (status === Status.FAILURE)
88
- return (_d = (_c = slots.fallback) == null ? void 0 : _c.call(slots)) != null ? _d : h(Loading);
85
+ if (status === Status.FAILURE || pingStatus === "unconnected") {
86
+ const node = (_a = slots.fallback) == null ? void 0 : _a.call(slots);
87
+ const title = (_b = payload.renderLoadFailedTitle) == null ? void 0 : _b.call(payload, status);
88
+ const description = (_c = payload.renderLoadFailedDescription) == null ? void 0 : _c.call(payload, status);
89
+ return node ? h("div", [node]) : h(LoadFailed, {
90
+ "attrs": {
91
+ "title": title,
92
+ "description": description
93
+ }
94
+ });
95
+ }
96
+ if (status === Status.LOADING || status === Status.SUCCESS && pingStatus === "pending") {
97
+ const node = (_d = slots.loading) == null ? void 0 : _d.call(slots);
98
+ return node ? h("div", [node]) : h(Loading);
99
+ }
89
100
  const children = (_e = slots.default) == null ? void 0 : _e.call(slots);
90
101
  const outArea = (_f = slots.outerArea) == null ? void 0 : _f.call(slots);
91
102
  const mapId = patchGmapIdForAlipayCompatible({
@@ -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
+ }
@@ -6,6 +6,7 @@ import type { Slot as Slot_V2 } from "vue2/types/v3-setup-context";
6
6
  import type { ScopedSlot as ScopedSlot_V2 } from "vue2/types/vnode";
7
7
  import type { DefineComponent as DefineComponent_V3, HTMLAttributes as HTMLAttributes_V3, ImgHTMLAttributes as ImgHTMLAttributes_V3, Ref as Ref_V3, Slot as Slot_V3, StyleValue as StyleValue_V3, VNodeArrayChildren as VNodeArrayChildren_V3, VNodeChild as VNodeChild_V3, VNode as VNode_V3, WatchOptions as WatchOptions_V3 } from "vue3";
8
8
  export * from "vue-demi";
9
+ export type { StyleValue_V2 };
9
10
  export type { Data } from "vue2";
10
11
  export type { EmitFn } from "vue2/types/v3-setup-context";
11
12
  export type { ComponentObjectPropsOptions, ObjectEmitsOptions, PublicProps, SlotsType } from "vue3";
@@ -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
  };
@@ -1,8 +1,8 @@
1
1
  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
- import type { VueNode } from "../demi-polyfill";
5
- import type { Language } from "../types/interface";
4
+ import type { VNodeChild } from "../demi-polyfill";
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,40 +19,47 @@ 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;
26
26
  version?: string;
27
27
  plugins?: `AMap.${AMap.PluginName}`[];
28
+ disableRef?: Ref<boolean>;
28
29
  }
29
30
  export declare const useAmapLoader: (props: AmapLoaderProps) => {
30
31
  statusRef: import("vue-demi").ShallowRef<Status>;
32
+ pingStatusRef: import("vue-demi").ShallowRef<ConnectionStatus>;
31
33
  readyPromise: Promise<undefined>;
32
34
  };
33
35
  export interface GmapLoaderProps extends LoaderOptions {
36
+ disableRef?: Ref<boolean>;
34
37
  /**
35
38
  * Render prop used to switch to loading component.
36
39
  */
37
- loading?: () => VueNode;
40
+ loading?: () => VNodeChild;
38
41
  /**
39
42
  * Render prop used to switch to error fallback component.
40
43
  */
41
- fallback?: () => VueNode;
44
+ fallback?: () => VNodeChild;
42
45
  /**
43
- * Callback prop used to access `@googlemaps/js-api-loader` and `Status`.
44
- *
45
- * Note: The callback be executed multiple times in the lifecycle of the component.
46
+ * 成功回调只会触发一次
46
47
  */
47
- onChange?: (status: Status) => void;
48
+ onSuccess?: () => void;
49
+ /**
50
+ * 失败回调可能会触发多次
51
+ */
52
+ onFail?: () => void;
48
53
  }
49
54
  export declare const useGmapLoader: (props: GmapLoaderProps) => {
50
55
  statusRef: import("vue-demi").ShallowRef<Status>;
56
+ pingStatusRef: import("vue-demi").ShallowRef<ConnectionStatus>;
51
57
  readyPromise: Promise<undefined>;
52
58
  };
53
59
  export type MapSupplier = "gmap" | "amap";
54
60
  export interface UseMapLoaderOutput {
55
61
  statusRef: Ref<Status>;
62
+ pingStatusRef: Ref<ConnectionStatus>;
56
63
  readyPromise: Promise<undefined>;
57
64
  }
58
65
  export interface UseMapLoaderProps {
@@ -62,7 +69,8 @@ export interface UseMapLoaderProps {
62
69
  amapServiceHost?: string;
63
70
  supplier: MapSupplier;
64
71
  language: Language;
65
- onChange?: (status: Status) => any;
72
+ onSuccess?: () => void;
73
+ onFail?: () => void;
66
74
  }
67
75
  export declare const useMapLoader: (props: UseMapLoaderProps) => UseMapLoaderOutput;
68
76
  export {};