@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.
- package/README.md +45 -52
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/v2/App.js +8 -4
- package/dist/v2/Demo/DemoBusinessQuoting.js +6 -12
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +3 -8
- package/dist/v2/Demo/DemoBusinessReselectPlace.js +2 -7
- package/dist/v2/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
- package/dist/v2/Demo/DemoBusinessTaxiEnd.js +2 -18
- package/dist/v2/Demo/DemoBusinessTaxiService.d.ts +1 -2392
- package/dist/v2/Demo/DemoBusinessTaxiService.js +6 -19
- package/dist/v2/api/cdn.d.ts +1 -0
- package/dist/v2/api/cdn.js +2 -0
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +5 -5
- package/dist/v2/business-components/BusinessQuotingMap/BusinessQuotingMap.js +42 -11
- package/dist/v2/business-components/BusinessQuotingMap/index.js +3 -2
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +2 -3
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +4 -2
- package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +2 -1
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +3 -2
- package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +44 -17
- package/dist/v2/business-components/BusinessReselectPlaceMap/index.js +3 -2
- package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +2 -3
- package/dist/v2/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
- package/dist/v2/business-components/BusinessTaxiEndMap/index.js +3 -2
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +5 -5
- package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +42 -18
- package/dist/v2/business-components/BusinessTaxiServiceMap/index.js +3 -2
- package/dist/v2/chunks/{BusinessRecomendPlaceMap.87ea3b2f.js → BusinessRecomendPlaceMap.5be4fdcf.js} +38 -15
- package/dist/v2/chunks/{Loading.fc6e75d0.js → Loading.da68a2a6.js} +31 -1
- package/dist/v2/chunks/throttle.8bdd8d3b.js +20 -0
- package/dist/v2/components/AmapMarker/AmapMarker.js +2 -1
- package/dist/v2/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
- package/dist/v2/components/Loading/Loading.css.d.ts +5 -0
- package/dist/v2/components/Loading/Loading.d.ts +6 -0
- package/dist/v2/components/Loading/Loading.js +3 -1
- package/dist/v2/components/Loading/index.js +2 -1
- package/dist/v2/components/MapProvider/MapProvider.d.ts +2 -2
- package/dist/v2/components/MapProvider/MapProvider.js +20 -12
- package/dist/v2/css/Loading-0e058b68.css +51 -0
- package/dist/v2/demi-polyfill/demi-polyfill.d.ts +1 -0
- package/dist/v2/hooks/useDeviceOrientation.js +1 -17
- package/dist/v2/hooks/useMapGCJ02.js +1 -3
- package/dist/v2/hooks/useMapGraspRoad.js +1 -2
- package/dist/v2/hooks/useMapInChina.d.ts +3 -15
- package/dist/v2/hooks/useMapInChina.js +11 -16
- package/dist/v2/hooks/useMapLoader.d.ts +15 -9
- package/dist/v2/hooks/useMapLoader.js +105 -64
- package/dist/v2/hooks/useMapPlace.js +1 -2
- package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v2/hooks-business/useBusinessAlarm.d.ts +3 -0
- package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
- package/dist/v2/hooks-business/useBusinessQuotingMap.js +10 -10
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
- package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
- package/dist/v2/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
- package/dist/v2/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
- package/dist/v2/hooks-business/useBusinessTaxiServiceMap.js +5 -10
- package/dist/v2/index.js +1 -1
- package/dist/v2/utils/compare.d.ts +4 -0
- package/dist/v2/utils/compare.js +6 -0
- package/dist/v2/utils/helper.d.ts +4 -0
- package/dist/v2/utils/helper.js +14 -0
- package/dist/v2/utils/log.js +1 -1
- package/dist/v3/App.js +8 -4
- package/dist/v3/Demo/DemoBusinessQuoting.js +7 -13
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +3 -8
- package/dist/v3/Demo/DemoBusinessReselectPlace.js +2 -7
- package/dist/v3/Demo/DemoBusinessTaxiEnd.d.ts +1 -3
- package/dist/v3/Demo/DemoBusinessTaxiEnd.js +3 -17
- package/dist/v3/Demo/DemoBusinessTaxiService.d.ts +1 -2392
- package/dist/v3/Demo/DemoBusinessTaxiService.js +6 -17
- package/dist/v3/api/cdn.d.ts +1 -0
- package/dist/v3/api/cdn.js +2 -0
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.d.ts +16 -7
- package/dist/v3/business-components/BusinessQuotingMap/BusinessQuotingMap.js +42 -11
- package/dist/v3/business-components/BusinessQuotingMap/index.js +3 -2
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +10 -3
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +4 -2
- package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +2 -1
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +10 -2
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +44 -17
- package/dist/v3/business-components/BusinessReselectPlaceMap/index.js +3 -2
- package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.d.ts +4 -3
- package/dist/v3/business-components/BusinessTaxiEndMap/BusinessTaxiEndMap.js +22 -8
- package/dist/v3/business-components/BusinessTaxiEndMap/index.js +3 -2
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +19 -7
- package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +42 -18
- package/dist/v3/business-components/BusinessTaxiServiceMap/index.js +3 -2
- package/dist/v3/chunks/{BusinessRecomendPlaceMap.57b15c64.js → BusinessRecomendPlaceMap.39888296.js} +38 -15
- package/dist/v3/chunks/{Loading.a8e2f26a.js → Loading.98d687c0.js} +27 -1
- package/dist/v3/chunks/throttle.8bdd8d3b.js +20 -0
- package/dist/v3/components/AmapMarker/AmapMarker.js +2 -1
- package/dist/v3/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
- package/dist/v3/components/Loading/Loading.css.d.ts +5 -0
- package/dist/v3/components/Loading/Loading.d.ts +8 -0
- package/dist/v3/components/Loading/Loading.js +3 -1
- package/dist/v3/components/Loading/index.js +2 -1
- package/dist/v3/components/MapProvider/MapProvider.d.ts +6 -3
- package/dist/v3/components/MapProvider/MapProvider.js +18 -12
- package/dist/v3/css/Loading-0e058b68.css +51 -0
- package/dist/v3/demi-polyfill/demi-polyfill.d.ts +1 -0
- package/dist/v3/hooks/useDeviceOrientation.js +1 -17
- package/dist/v3/hooks/useMapGCJ02.js +1 -3
- package/dist/v3/hooks/useMapGraspRoad.js +1 -2
- package/dist/v3/hooks/useMapInChina.d.ts +3 -15
- package/dist/v3/hooks/useMapInChina.js +11 -16
- package/dist/v3/hooks/useMapLoader.d.ts +15 -9
- package/dist/v3/hooks/useMapLoader.js +105 -64
- package/dist/v3/hooks/useMapPlace.js +1 -2
- package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
- package/dist/v3/hooks-business/useBusinessAlarm.d.ts +3 -0
- package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +7 -2393
- package/dist/v3/hooks-business/useBusinessQuotingMap.js +10 -10
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.d.ts +8 -17
- package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +8 -34
- package/dist/v3/hooks-business/useBusinessReselectPlaceMap.d.ts +4 -13
- package/dist/v3/hooks-business/useBusinessTaxiServiceMap.d.ts +5 -2393
- package/dist/v3/hooks-business/useBusinessTaxiServiceMap.js +5 -10
- package/dist/v3/index.js +1 -1
- package/dist/v3/utils/compare.d.ts +4 -0
- package/dist/v3/utils/compare.js +6 -0
- package/dist/v3/utils/helper.d.ts +4 -0
- package/dist/v3/utils/helper.js +14 -0
- package/dist/v3/utils/log.js +1 -1
- package/package.json +1 -1
- package/dist/v2/Demo/Demo.d.ts +0 -3
- package/dist/v2/Demo/Demo.js +0 -1634
- package/dist/v2/components/AmapLoader/AmapLoader.d.ts +0 -5
- package/dist/v2/components/AmapLoader/AmapLoader.js +0 -21
- package/dist/v2/components/AmapLoader/index.d.ts +0 -1
- package/dist/v2/components/AmapLoader/index.js +0 -4
- package/dist/v2/components/GmapLoader/GmapLoader.d.ts +0 -5
- package/dist/v2/components/GmapLoader/GmapLoader.js +0 -21
- package/dist/v2/components/GmapLoader/index.d.ts +0 -1
- package/dist/v2/components/GmapLoader/index.js +0 -4
- package/dist/v2/css/Loading-523061b9.css +0 -9
- package/dist/v2/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
- package/dist/v2/hooks-business/useBusinessTaxiEndMap.js +0 -7
- package/dist/v3/Demo/Demo.d.ts +0 -9
- package/dist/v3/Demo/Demo.js +0 -1612
- package/dist/v3/components/AmapLoader/AmapLoader.d.ts +0 -10
- package/dist/v3/components/AmapLoader/AmapLoader.js +0 -21
- package/dist/v3/components/AmapLoader/index.d.ts +0 -1
- package/dist/v3/components/AmapLoader/index.js +0 -4
- package/dist/v3/components/GmapLoader/GmapLoader.d.ts +0 -10
- package/dist/v3/components/GmapLoader/GmapLoader.js +0 -21
- package/dist/v3/components/GmapLoader/index.d.ts +0 -1
- package/dist/v3/components/GmapLoader/index.js +0 -4
- package/dist/v3/css/Loading-523061b9.css +0 -9
- package/dist/v3/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
- 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 {
|
|
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" | "
|
|
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?: () =>
|
|
40
|
+
loading?: () => VNodeChild;
|
|
38
41
|
/**
|
|
39
42
|
* Render prop used to switch to error fallback component.
|
|
40
43
|
*/
|
|
41
|
-
fallback?: () =>
|
|
44
|
+
fallback?: () => VNodeChild;
|
|
42
45
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Note: The callback be executed multiple times in the lifecycle of the component.
|
|
46
|
+
* 成功回调只会触发一次
|
|
46
47
|
*/
|
|
47
|
-
|
|
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
|
-
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
570
|
-
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
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
|
-
|
|
598
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
599
|
+
},
|
|
600
|
+
() => {
|
|
601
|
+
statusRef.value = "FAILURE";
|
|
577
602
|
rejectLoader();
|
|
578
|
-
|
|
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 {
|
|
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 {
|
|
633
|
+
const { onSuccess: onSuccess2, onFail: onFail2, fallback, loading, language, ...options } = props;
|
|
619
634
|
return options;
|
|
620
635
|
});
|
|
621
|
-
|
|
622
|
-
|
|
636
|
+
const timerRef = ref();
|
|
637
|
+
const reload = throttle(
|
|
623
638
|
(options) => {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
-
|
|
655
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
656
|
+
},
|
|
657
|
+
() => {
|
|
658
|
+
clearTimeout(timerRef.value);
|
|
659
|
+
statusRef.value = "FAILURE";
|
|
630
660
|
rejectLoader();
|
|
631
|
-
|
|
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,
|
|
653
|
-
|
|
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
|
-
|
|
661
|
-
|
|
662
|
-
|
|
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 {
|
|
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;
|