@heycar/heycars-map 1.0.0-coordinate7 → 2.0.0-switchMap2

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 (152) 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/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +5 -5
  15. package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +42 -11
  16. package/dist/v2/business-components/BusinessQuotingMap/index.js +3 -2
  17. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -3
  18. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +4 -2
  19. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +2 -1
  20. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +3 -2
  21. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +44 -17
  22. package/dist/v2/business-components/BusinessReselectPlaceMap/index.js +3 -2
  23. package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +2 -3
  24. package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
  25. package/dist/v2/business-components/BusinessTaxiEndMap/index.js +3 -2
  26. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +5 -5
  27. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +42 -18
  28. package/dist/v2/business-components/BusinessTaxiServiceMap/index.js +3 -2
  29. package/dist/v2/chunks/{BusinessRecomendPlaceMap.87ea3b2f.js → BusinessRecomendPlaceMap.5be4fdcf.js} +38 -15
  30. package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.da68a2a6.js} +31 -1
  31. package/dist/v2/chunks/throttle.8bdd8d3b.js +20 -0
  32. package/dist/v2/components/AmapMarker/AmapMarker.js +2 -1
  33. package/dist/v2/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
  34. package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
  35. package/dist/v2/components/Loading/Loading.d.ts +6 -0
  36. package/dist/v2/components/Loading/Loading.js +3 -1
  37. package/dist/v2/components/Loading/index.js +2 -1
  38. package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
  39. package/dist/v2/components/MapProvider/MapProvider.js +20 -12
  40. package/dist/v2/css/Loading-0e058b68.css +51 -0
  41. package/dist/v2/demi-polyfill/demi-polyfill.d.ts +1 -0
  42. package/dist/v2/hooks/useDeviceOrientation.js +1 -17
  43. package/dist/v2/hooks/useMapGCJ02.js +1 -3
  44. package/dist/v2/hooks/useMapGraspRoad.js +1 -2
  45. package/dist/v2/hooks/useMapInChina.d.ts +3 -15
  46. package/dist/v2/hooks/useMapInChina.js +11 -16
  47. package/dist/v2/hooks/useMapLoader.d.ts +15 -9
  48. package/dist/v2/hooks/useMapLoader.js +105 -64
  49. package/dist/v2/hooks/useMapPlace.js +1 -2
  50. package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
  51. package/dist/v2/hooks-business/useBusinessAlarm.d.ts +3 -0
  52. package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
  53. package/dist/v2/hooks-business/useBusinessQuotingMap.js +10 -10
  54. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
  55. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
  56. package/dist/v2/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
  57. package/dist/v2/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
  58. package/dist/v2/hooks-business/useBusinessTaxiServiceMap.js +5 -10
  59. package/dist/v2/index.js +1 -1
  60. package/dist/v2/utils/compare.d.ts +4 -0
  61. package/dist/v2/utils/compare.js +6 -0
  62. package/dist/v2/utils/helper.d.ts +4 -0
  63. package/dist/v2/utils/helper.js +14 -0
  64. package/dist/v2/utils/log.js +1 -1
  65. package/dist/v3/App.js +8 -4
  66. package/dist/v3/Demo/DemoBusinessQuoting.js +7 -13
  67. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +3 -8
  68. package/dist/v3/Demo/DemoBusinessReselectPlace.js +2 -7
  69. package/dist/v3/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
  70. package/dist/v3/Demo/DemoBusinessTaxiEnd.js +3 -17
  71. package/dist/v3/Demo/DemoBusinessTaxiService.d.ts +1 -2392
  72. package/dist/v3/Demo/DemoBusinessTaxiService.js +6 -17
  73. package/dist/v3/api/cdn.d.ts +1 -0
  74. package/dist/v3/api/cdn.js +2 -0
  75. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +16 -7
  76. package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +42 -11
  77. package/dist/v3/business-components/BusinessQuotingMap/index.js +3 -2
  78. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +10 -3
  79. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +4 -2
  80. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +2 -1
  81. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +10 -2
  82. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +44 -17
  83. package/dist/v3/business-components/BusinessReselectPlaceMap/index.js +3 -2
  84. package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
  85. package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
  86. package/dist/v3/business-components/BusinessTaxiEndMap/index.js +3 -2
  87. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +19 -7
  88. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +42 -18
  89. package/dist/v3/business-components/BusinessTaxiServiceMap/index.js +3 -2
  90. package/dist/v3/chunks/{BusinessRecomendPlaceMap.57b15c64.js → BusinessRecomendPlaceMap.39888296.js} +38 -15
  91. package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.98d687c0.js} +27 -1
  92. package/dist/v3/chunks/throttle.8bdd8d3b.js +20 -0
  93. package/dist/v3/components/AmapMarker/AmapMarker.js +2 -1
  94. package/dist/v3/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
  95. package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
  96. package/dist/v3/components/Loading/Loading.d.ts +8 -0
  97. package/dist/v3/components/Loading/Loading.js +3 -1
  98. package/dist/v3/components/Loading/index.js +2 -1
  99. package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
  100. package/dist/v3/components/MapProvider/MapProvider.js +18 -12
  101. package/dist/v3/css/Loading-0e058b68.css +51 -0
  102. package/dist/v3/demi-polyfill/demi-polyfill.d.ts +1 -0
  103. package/dist/v3/hooks/useDeviceOrientation.js +1 -17
  104. package/dist/v3/hooks/useMapGCJ02.js +1 -3
  105. package/dist/v3/hooks/useMapGraspRoad.js +1 -2
  106. package/dist/v3/hooks/useMapInChina.d.ts +3 -15
  107. package/dist/v3/hooks/useMapInChina.js +11 -16
  108. package/dist/v3/hooks/useMapLoader.d.ts +15 -9
  109. package/dist/v3/hooks/useMapLoader.js +105 -64
  110. package/dist/v3/hooks/useMapPlace.js +1 -2
  111. package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
  112. package/dist/v3/hooks-business/useBusinessAlarm.d.ts +3 -0
  113. package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
  114. package/dist/v3/hooks-business/useBusinessQuotingMap.js +10 -10
  115. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
  116. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
  117. package/dist/v3/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
  118. package/dist/v3/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
  119. package/dist/v3/hooks-business/useBusinessTaxiServiceMap.js +5 -10
  120. package/dist/v3/index.js +1 -1
  121. package/dist/v3/utils/compare.d.ts +4 -0
  122. package/dist/v3/utils/compare.js +6 -0
  123. package/dist/v3/utils/helper.d.ts +4 -0
  124. package/dist/v3/utils/helper.js +14 -0
  125. package/dist/v3/utils/log.js +1 -1
  126. package/package.json +1 -1
  127. package/dist/v2/Demo/Demo.d.ts +0 -3
  128. package/dist/v2/Demo/Demo.js +0 -1634
  129. package/dist/v2/components/AmapLoader/AmapLoader.d.ts +0 -5
  130. package/dist/v2/components/AmapLoader/AmapLoader.js +0 -21
  131. package/dist/v2/components/AmapLoader/index.d.ts +0 -1
  132. package/dist/v2/components/AmapLoader/index.js +0 -4
  133. package/dist/v2/components/GmapLoader/GmapLoader.d.ts +0 -5
  134. package/dist/v2/components/GmapLoader/GmapLoader.js +0 -21
  135. package/dist/v2/components/GmapLoader/index.d.ts +0 -1
  136. package/dist/v2/components/GmapLoader/index.js +0 -4
  137. package/dist/v2/css/Loading-523061b9.css +0 -9
  138. package/dist/v2/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
  139. package/dist/v2/hooks-business/useBusinessTaxiEndMap.js +0 -7
  140. package/dist/v3/Demo/Demo.d.ts +0 -9
  141. package/dist/v3/Demo/Demo.js +0 -1612
  142. package/dist/v3/components/AmapLoader/AmapLoader.d.ts +0 -10
  143. package/dist/v3/components/AmapLoader/AmapLoader.js +0 -21
  144. package/dist/v3/components/AmapLoader/index.d.ts +0 -1
  145. package/dist/v3/components/AmapLoader/index.js +0 -4
  146. package/dist/v3/components/GmapLoader/GmapLoader.d.ts +0 -10
  147. package/dist/v3/components/GmapLoader/GmapLoader.js +0 -21
  148. package/dist/v3/components/GmapLoader/index.d.ts +0 -1
  149. package/dist/v3/components/GmapLoader/index.js +0 -4
  150. package/dist/v3/css/Loading-523061b9.css +0 -9
  151. package/dist/v3/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
  152. package/dist/v3/hooks-business/useBusinessTaxiEndMap.js +0 -7
@@ -1,12 +1,13 @@
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";
4
+ import type { VNodeChild } from "../demi-polyfill";
5
5
  import type { 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 {
9
9
  LOADING = "LOADING",
10
+ TIMEOUT = "TIMEOUT",
10
11
  FAILURE = "FAILURE",
11
12
  SUCCESS = "SUCCESS"
12
13
  }
@@ -19,32 +20,36 @@ declare global {
19
20
  };
20
21
  }
21
22
  }
22
- export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loading" | "onChange">, Omit<AMapLoaderOptions, "key" | "version" | "plugins"> {
23
+ export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loading" | "onSuccess" | "onFail">, Omit<AMapLoaderOptions, "key" | "version" | "plugins"> {
23
24
  apiKey: string;
24
25
  apiSecret?: string;
25
26
  apiServiceHost?: string;
26
27
  version?: string;
27
28
  plugins?: `AMap.${AMap.PluginName}`[];
29
+ disableRef?: Ref<boolean>;
28
30
  }
29
31
  export declare const useAmapLoader: (props: AmapLoaderProps) => {
30
32
  statusRef: import("vue-demi").ShallowRef<Status>;
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>;
@@ -62,7 +67,8 @@ export interface UseMapLoaderProps {
62
67
  amapServiceHost?: string;
63
68
  supplier: MapSupplier;
64
69
  language: Language;
65
- onChange?: (status: Status) => any;
70
+ onSuccess?: () => void;
71
+ onFail?: () => void;
66
72
  }
67
73
  export declare const useMapLoader: (props: UseMapLoaderProps) => UseMapLoaderOutput;
68
74
  export {};
@@ -1,6 +1,7 @@
1
- import { shallowRef, computed } from "vue-demi";
1
+ import { shallowRef, computed, ref } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
3
  import { createRunOnce } from "../utils/helper.js";
4
+ import { t as throttle } from "../chunks/throttle.8bdd8d3b.js";
4
5
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
5
6
  var distExports = {};
6
7
  var dist = {
@@ -537,6 +538,8 @@ class Loader {
537
538
  }
538
539
  }
539
540
  }
541
+ const MIN_MAP_RELOAD_INTERVAL = 5e3;
542
+ const GMAP_LOAD_TIMEOUT = 1e4;
540
543
  const DEFAULT_AMAP_PLUGINS = [
541
544
  "AMap.Geocoder",
542
545
  "AMap.Driving",
@@ -546,12 +549,13 @@ const DEFAULT_AMAP_PLUGINS = [
546
549
  const DEFAULT_GMAP_LIBRARIES = ["marker", "geometry"];
547
550
  var Status = /* @__PURE__ */ ((Status2) => {
548
551
  Status2["LOADING"] = "LOADING";
552
+ Status2["TIMEOUT"] = "TIMEOUT";
549
553
  Status2["FAILURE"] = "FAILURE";
550
554
  Status2["SUCCESS"] = "SUCCESS";
551
555
  return Status2;
552
556
  })(Status || {});
553
557
  const useAmapLoader = (props) => {
554
- const { onChange } = props;
558
+ const { disableRef, onSuccess, onFail } = props;
555
559
  let resolveLoader;
556
560
  let rejectLoader;
557
561
  const readyPromise = new Promise((resolve, reject) => {
@@ -563,47 +567,58 @@ const useAmapLoader = (props) => {
563
567
  /* LOADING */
564
568
  );
565
569
  const optionsRef = computed(() => {
566
- const { onChange: onChange2, loading, fallback, apiKey, apiSecret, apiServiceHost, version, ...options } = props;
570
+ const {
571
+ onSuccess: onSuccess2,
572
+ onFail: onFail2,
573
+ loading,
574
+ fallback,
575
+ apiKey,
576
+ apiSecret,
577
+ apiServiceHost,
578
+ version,
579
+ ...options
580
+ } = props;
567
581
  return { ...options, key: apiKey, version: version != null ? version : "2.0" };
568
582
  });
569
- watchPostEffectForDeepOption(
570
- () => optionsRef.value,
583
+ const defineSecurityOnce = createRunOnce(() => {
584
+ window._AMapSecurityConfig = props.apiServiceHost ? {
585
+ serviceHost: props.apiServiceHost
586
+ } : { securityJsCode: props.apiSecret };
587
+ });
588
+ const reload = throttle(
571
589
  (options) => {
572
- const setStatusAndExecuteCallback = (status) => {
573
- statusRef.value = status;
574
- if (status === "SUCCESS")
590
+ if (statusRef.value === "SUCCESS")
591
+ return;
592
+ statusRef.value = "LOADING";
593
+ defineSecurityOnce();
594
+ return distExports.load(options).then(
595
+ () => {
596
+ statusRef.value = "SUCCESS";
575
597
  resolveLoader();
576
- if (status === "FAILURE")
598
+ onSuccess == null ? void 0 : onSuccess();
599
+ },
600
+ () => {
601
+ statusRef.value = "FAILURE";
577
602
  rejectLoader();
578
- onChange == null ? void 0 : onChange(statusRef.value);
579
- };
580
- setStatusAndExecuteCallback(
581
- "LOADING"
582
- /* LOADING */
583
- );
584
- window._AMapSecurityConfig = props.apiServiceHost ? {
585
- serviceHost: props.apiServiceHost
586
- } : { securityJsCode: props.apiSecret };
587
- distExports.load(options).then(
588
- () => setStatusAndExecuteCallback(
589
- "SUCCESS"
590
- /* SUCCESS */
591
- ),
592
- () => setStatusAndExecuteCallback(
593
- "FAILURE"
594
- /* FAILURE */
595
- )
603
+ onFail == null ? void 0 : onFail();
604
+ }
596
605
  );
606
+ },
607
+ MIN_MAP_RELOAD_INTERVAL,
608
+ { trailing: false }
609
+ );
610
+ watchPostEffectForDeepOption(
611
+ () => [optionsRef.value, disableRef == null ? void 0 : disableRef.value],
612
+ ([options, disable]) => {
613
+ if (disable)
614
+ return;
615
+ reload(options);
597
616
  }
598
617
  );
599
618
  return { statusRef, readyPromise };
600
619
  };
601
- const loadGmapOnce = createRunOnce((opts) => {
602
- const loader = new Loader(opts);
603
- return loader.load();
604
- });
605
620
  const useGmapLoader = (props) => {
606
- const { onChange } = props;
621
+ const { disableRef, onSuccess, onFail } = props;
607
622
  let resolveLoader;
608
623
  let rejectLoader;
609
624
  const readyPromise = new Promise((resolve, reject) => {
@@ -615,56 +630,82 @@ const useGmapLoader = (props) => {
615
630
  /* LOADING */
616
631
  );
617
632
  const optionsRef = computed(() => {
618
- const { onChange: onChange2, fallback, loading, language, ...options } = props;
633
+ const { onSuccess: onSuccess2, onFail: onFail2, fallback, loading, language, ...options } = props;
619
634
  return options;
620
635
  });
621
- watchPostEffectForDeepOption(
622
- () => optionsRef.value,
636
+ const timerRef = ref();
637
+ const reload = throttle(
623
638
  (options) => {
624
- const language = navigator.language;
625
- const setStatusAndExecuteCallback = (status) => {
626
- statusRef.value = status;
627
- if (status === "SUCCESS")
639
+ if (statusRef.value === "SUCCESS")
640
+ return;
641
+ const loader = new Loader(options);
642
+ clearTimeout(timerRef.value);
643
+ timerRef.value = window.setTimeout(() => {
644
+ statusRef.value = "TIMEOUT";
645
+ }, GMAP_LOAD_TIMEOUT);
646
+ if (loader.status !== LoaderStatus.INITIALIZED) {
647
+ loader.reset();
648
+ }
649
+ statusRef.value = "LOADING";
650
+ return loader.load().then(
651
+ () => {
652
+ clearTimeout(timerRef.value);
653
+ statusRef.value = "SUCCESS";
628
654
  resolveLoader();
629
- if (status === "FAILURE")
655
+ onSuccess == null ? void 0 : onSuccess();
656
+ },
657
+ () => {
658
+ clearTimeout(timerRef.value);
659
+ statusRef.value = "FAILURE";
630
660
  rejectLoader();
631
- onChange == null ? void 0 : onChange(statusRef.value);
632
- };
633
- setStatusAndExecuteCallback(
634
- "LOADING"
635
- /* LOADING */
636
- );
637
- loadGmapOnce({ ...options, language }).then(
638
- () => setStatusAndExecuteCallback(
639
- "SUCCESS"
640
- /* SUCCESS */
641
- ),
642
- () => setStatusAndExecuteCallback(
643
- "FAILURE"
644
- /* FAILURE */
645
- )
661
+ onFail == null ? void 0 : onFail();
662
+ }
646
663
  );
664
+ },
665
+ MIN_MAP_RELOAD_INTERVAL,
666
+ { trailing: false }
667
+ );
668
+ watchPostEffectForDeepOption(
669
+ () => [optionsRef.value, disableRef == null ? void 0 : disableRef.value],
670
+ ([options, disable]) => {
671
+ if (disable)
672
+ return;
673
+ const language = navigator.language;
674
+ reload({ ...options, language });
647
675
  }
648
676
  );
649
677
  return { statusRef, readyPromise };
650
678
  };
651
679
  const useMapLoader = (props) => {
652
- const { gmapKey, amapKey, amapSecret, amapServiceHost, supplier, language, onChange } = props;
653
- return supplier === "gmap" ? useGmapLoader({
680
+ const { gmapKey, amapKey, amapSecret, amapServiceHost, language, onSuccess, onFail } = props;
681
+ const { statusRef: amapStatusRef, readyPromise: amapReadyPromise } = useAmapLoader({
682
+ apiKey: amapKey,
683
+ apiSecret: amapSecret,
684
+ apiServiceHost: amapServiceHost,
685
+ plugins: DEFAULT_AMAP_PLUGINS,
686
+ disableRef: computed(() => props.supplier !== "amap"),
687
+ onSuccess,
688
+ onFail
689
+ });
690
+ const { statusRef: gmapStatusRef, readyPromise: gmapReadyPromise } = useGmapLoader({
654
691
  apiKey: gmapKey,
655
692
  language,
656
693
  version: "weekly",
657
694
  // todo: 需要提前设置 region
658
695
  // region: "CN",
659
696
  libraries: DEFAULT_GMAP_LIBRARIES,
660
- onChange
661
- }) : useAmapLoader({
662
- apiKey: amapKey,
663
- apiSecret: amapSecret,
664
- apiServiceHost: amapServiceHost,
665
- plugins: DEFAULT_AMAP_PLUGINS,
666
- onChange
697
+ disableRef: computed(() => props.supplier !== "gmap"),
698
+ onSuccess,
699
+ onFail
667
700
  });
701
+ return {
702
+ get statusRef() {
703
+ return props.supplier === "gmap" ? gmapStatusRef : amapStatusRef;
704
+ },
705
+ get readyPromise() {
706
+ return props.supplier === "gmap" ? gmapReadyPromise : amapReadyPromise;
707
+ }
708
+ };
668
709
  };
669
710
  export {
670
711
  DEFAULT_AMAP_PLUGINS,
@@ -3,7 +3,7 @@ import { REGEO_TIMEOUT } from "../api/contants.js";
3
3
  import { createPipeTw } from "../utils/cn2tw.js";
4
4
  import { equalAssign } from "../utils/helper.js";
5
5
  import { amapPlaceName2DisplayName, gmapPlaceName2DisplayName } from "../utils/transform.js";
6
- import { useAmapInChina } from "./useMapInChina.js";
6
+ import { inChina } from "./useMapInChina.js";
7
7
  import { useMapSupplier } from "./useMapSupplier.js";
8
8
  import { useUpdate } from "./useUdate.js";
9
9
  const useAmapPlace = (props) => {
@@ -11,7 +11,6 @@ const useAmapPlace = (props) => {
11
11
  const defaultPoint = [...props.pointRef.value];
12
12
  const pointRef = ref(defaultPoint);
13
13
  const { readyPromise, language } = useMapSupplier();
14
- const { inChina } = useAmapInChina();
15
14
  const place = reactive({
16
15
  lng: pointRef.value[0],
17
16
  lat: pointRef.value[1],
@@ -4,6 +4,8 @@ export interface MapSupplierPayolad extends UseMapLoaderProps {
4
4
  gmapId: string;
5
5
  readyPromise: UseMapLoaderOutput["readyPromise"];
6
6
  status: Status;
7
+ renderLoadFailedTitle?: (status: Status) => string | undefined;
8
+ renderLoadFailedDescription?: (status: Status) => string | undefined;
7
9
  }
8
10
  export declare const useMapSupplier: () => MapSupplierPayolad;
9
11
  export declare const provideMapSupplier: (payload: MapSupplierPayolad) => void;
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @warning: 如果要支持动态地图切换, 外部引用 useBusinessAlarm 的组件必须利用 key={mapSupplier} 强制更新
3
+ */
1
4
  export interface useBusinessAlarmProps {
2
5
  emptyPlaceName: string;
3
6
  }