@heycar/heycars-map 1.0.0-coordinate7 → 2.0.0-switchMap1
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 +4 -25
- package/dist/v2/App.js +6 -4
- package/dist/v2/Demo/DemoBusinessQuoting.js +4 -11
- 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/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/components/AmapMarker/AmapMarker.js +2 -1
- package/dist/v2/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
- package/dist/v2/components/MapProvider/MapProvider.js +16 -15
- package/dist/v2/demi-polyfill/demi-polyfill.d.ts +1 -0
- package/dist/v2/hooks/useMapLoader.d.ts +5 -3
- package/dist/v2/hooks/useMapLoader.js +29 -14
- package/dist/v2/hooks-business/useBusinessAlarm.d.ts +3 -0
- package/dist/v2/hooks-business/useBusinessQuotingMap.d.ts +5 -2393
- package/dist/v2/hooks-business/useBusinessQuotingMap.js +5 -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 +6 -4
- package/dist/v3/Demo/DemoBusinessQuoting.js +4 -11
- 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/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/components/AmapMarker/AmapMarker.js +2 -1
- package/dist/v3/components/GmapAdvancedMarkerElement/GmapAdvancedMarkerElement.js +1 -1
- package/dist/v3/components/MapProvider/MapProvider.js +16 -15
- package/dist/v3/demi-polyfill/demi-polyfill.d.ts +1 -0
- package/dist/v3/hooks/useMapLoader.d.ts +5 -3
- package/dist/v3/hooks/useMapLoader.js +29 -14
- package/dist/v3/hooks-business/useBusinessAlarm.d.ts +3 -0
- package/dist/v3/hooks-business/useBusinessQuotingMap.d.ts +5 -2393
- package/dist/v3/hooks-business/useBusinessQuotingMap.js +5 -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/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/hooks-business/useBusinessTaxiEndMap.d.ts +0 -3
- package/dist/v3/hooks-business/useBusinessTaxiEndMap.js +0 -7
package/dist/v2/chunks/{BusinessRecomendPlaceMap.87ea3b2f.js → BusinessRecomendPlaceMap.5be4fdcf.js}
RENAMED
|
@@ -3,21 +3,22 @@ import { computed, watch, watchEffect } from "vue-demi";
|
|
|
3
3
|
import { apiSaveCenterPlaceToCache } from "../api/browser.js";
|
|
4
4
|
import { apiMemoryShouldSkipByKey } from "../api/memory.js";
|
|
5
5
|
import { HeycarMap } from "../components/MapProvider/MapProvider.js";
|
|
6
|
+
import { createElement } from "../demi-polyfill/demi-polyfill.js";
|
|
6
7
|
import { useGeoLocation } from "../hooks/useGeoLocation.js";
|
|
7
|
-
import { useGoogleConnection } from "../hooks/useGoogleConnection.js";
|
|
8
8
|
import { useHeycarMap } from "../hooks/useHeycarMap.js";
|
|
9
9
|
import { useMapCoordinatify } from "../hooks/useMapCoordinatify.js";
|
|
10
10
|
import { useMapDrag } from "../hooks/useMapDrag.js";
|
|
11
|
+
import { useMapGeometry } from "../hooks/useMapGeometry.js";
|
|
11
12
|
import { useMapRecomendPlace } from "../hooks/useMapRecomendPlace.js";
|
|
12
13
|
import { useMapSupplier } from "../hooks/useMapSupplier.js";
|
|
13
14
|
import { useMapZoom } from "../hooks/useMapZoom.js";
|
|
14
|
-
import { defineLagecySetup } from "../types/helper.js";
|
|
15
|
+
import { defineSetup, defineLagecySetup } from "../types/helper.js";
|
|
15
16
|
import { CenterPlaceStatus } from "../types/interface.js";
|
|
16
|
-
import { watchPostEffectOnce } from "../utils/compare.js";
|
|
17
|
+
import { watchPostEffectOnce, generateCreateElementV2PropsOn } from "../utils/compare.js";
|
|
17
18
|
import { equalAssign, isPlacesInclude } from "../utils/helper.js";
|
|
18
19
|
import { detectBrowserPlatform } from "../utils/platform.js";
|
|
19
20
|
import { place2point, isPlaceEqual, pipeOnlyLastEffect, isZoneEqual, geoPositionError2businessTimeout } from "../utils/transform.js";
|
|
20
|
-
import { toCoordinateRecommendZonePlacesType, toCoordinatePlaceType } from "../utils/typeChecking.js";
|
|
21
|
+
import { toCoordinatePointType, toCoordinateRecommendZonePlacesType, toCoordinatePlaceType } from "../utils/typeChecking.js";
|
|
21
22
|
import { AbsoluteAddressBox } from "../business-components/AbsoluteAddressBox/AbsoluteAddressBox.js";
|
|
22
23
|
import { DeviceOrientation } from "../business-components/DeviceOrientation/DeviceOrientation.js";
|
|
23
24
|
import { GreenZone } from "../business-components/GreenZone/GreenZone.js";
|
|
@@ -271,7 +272,7 @@ const EMPTY_PLACE = {
|
|
|
271
272
|
name: "",
|
|
272
273
|
displayName: ""
|
|
273
274
|
};
|
|
274
|
-
const
|
|
275
|
+
const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner", function(props, {
|
|
275
276
|
emit,
|
|
276
277
|
slots,
|
|
277
278
|
attrs
|
|
@@ -287,6 +288,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", f
|
|
|
287
288
|
} = props;
|
|
288
289
|
const {
|
|
289
290
|
coordinatifyPoint,
|
|
291
|
+
unCoordinatifyPoint,
|
|
290
292
|
coordinatifyPlace,
|
|
291
293
|
unCoordinatifyPlace,
|
|
292
294
|
unCoordinatifyRecommendZonePlaces,
|
|
@@ -295,6 +297,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", f
|
|
|
295
297
|
} = useMapCoordinatify();
|
|
296
298
|
const pipedGetAvailable = getAvailable && pipeOnlyLastEffect((p) => getAvailable(coordinatifyPlace(p)));
|
|
297
299
|
const pipedGetRecomendPlace = pipeOnlyLastEffect((p) => getRecomendPlace(coordinatifyPlace(p)).then((r) => r && unCoordinatifyRecommendZonePlaces(toCoordinateRecommendZonePlacesType(r))));
|
|
300
|
+
const {
|
|
301
|
+
apiMapDistance
|
|
302
|
+
} = useMapGeometry();
|
|
298
303
|
const {
|
|
299
304
|
mapRef,
|
|
300
305
|
mapElementRef,
|
|
@@ -413,9 +418,9 @@ const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", f
|
|
|
413
418
|
emitGeoErrorOnce(error);
|
|
414
419
|
}
|
|
415
420
|
});
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
421
|
+
mapContext.apiMapDistance = (from, to) => {
|
|
422
|
+
return apiMapDistance(unCoordinatifyPoint(toCoordinatePointType(from)), unCoordinatifyPoint(toCoordinatePointType(to)));
|
|
423
|
+
};
|
|
419
424
|
mapContext.setCenterPlaceByUserSpecified = setCenterPlaceByUserSpecified;
|
|
420
425
|
mapContext.setCenterPlaceByUserSpecifiedInZone = setCenterPlaceByUserSpecifiedInZone;
|
|
421
426
|
mapContext.panToGeoPositionByRecomend = () => {
|
|
@@ -495,22 +500,19 @@ const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", f
|
|
|
495
500
|
if (!isFirstLoad)
|
|
496
501
|
updateRecommendPlaceOnlyInZone(defaultCenterPlace);
|
|
497
502
|
});
|
|
498
|
-
watch(centerPlace, () => {
|
|
503
|
+
watch(centerPlace, (place) => {
|
|
499
504
|
if (centerPlaceStatusRef.value === CenterPlaceStatus.OK) {
|
|
500
505
|
apiSaveCenterPlaceToCache(coordinatifyPlace({
|
|
501
|
-
...
|
|
506
|
+
...place
|
|
502
507
|
}));
|
|
503
508
|
}
|
|
504
|
-
mapContext.
|
|
505
|
-
...
|
|
509
|
+
equalAssign(mapContext.centerPlace, coordinatifyPlace({
|
|
510
|
+
...place
|
|
506
511
|
}));
|
|
507
512
|
}, {
|
|
508
513
|
deep: true,
|
|
509
514
|
flush: "post"
|
|
510
515
|
});
|
|
511
|
-
watchEffect(() => {
|
|
512
|
-
mapContext.onChangeRecomendPlaces(placeCandidates.value.map(coordinatifyPlace));
|
|
513
|
-
});
|
|
514
516
|
watchEffect(() => {
|
|
515
517
|
mapContext.centerPlaceStatusRef.value = centerPlaceStatusRef.value;
|
|
516
518
|
});
|
|
@@ -579,6 +581,26 @@ const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", f
|
|
|
579
581
|
}
|
|
580
582
|
})]);
|
|
581
583
|
};
|
|
584
|
+
});
|
|
585
|
+
const BusinessRecomendPlaceMap = defineLagecySetup("BusinessRecomendPlaceMap", function(props, {
|
|
586
|
+
slots,
|
|
587
|
+
attrs,
|
|
588
|
+
emit
|
|
589
|
+
}) {
|
|
590
|
+
const payload = useMapSupplier();
|
|
591
|
+
const instanceNo = Date.now();
|
|
592
|
+
return () => createElement(BusinessRecomendPlaceMapInner, {
|
|
593
|
+
...attrs.class ? {
|
|
594
|
+
class: attrs.class
|
|
595
|
+
} : {},
|
|
596
|
+
...attrs.style ? {
|
|
597
|
+
style: attrs.style
|
|
598
|
+
} : {},
|
|
599
|
+
attrs: props,
|
|
600
|
+
scopedSlots: slots,
|
|
601
|
+
key: `${payload.supplier}${instanceNo}`,
|
|
602
|
+
on: generateCreateElementV2PropsOn(props, emit, ["loadGeoLocation", "loadDefaultGeoLocation", "changeByDrag", "changeGeoLocation", "changePlace", "changeRecomandPlace", "geoError", "geoErrorOnce", "clickLocatorText", "clickLocatorPhoto"])
|
|
603
|
+
});
|
|
582
604
|
}).props(["log", "geoLoadingTitle", "emptyTitle", "queryingTitle", "defaultCenterPlace", "geoErrorOnceNotificationKey", "unavailableTitle", "recomendDescription", "disableLocator", "fallback", "getRecomendPlace", "getAvailable", "renderPlacePhoto", "renderPlaceTag", "loading", "mapContext"]);
|
|
583
605
|
export {
|
|
584
606
|
BusinessRecomendPlaceMap as B,
|
|
@@ -591,5 +613,6 @@ export {
|
|
|
591
613
|
RECOMMEND_PLACE_ICON_ZOOM_MIN as c,
|
|
592
614
|
RECOMMEND_PLACE_ZONE_TEXT_MIN as d,
|
|
593
615
|
RECOMMEND_PLACE_TEXT_ZOOM_MIN as e,
|
|
616
|
+
BusinessRecomendPlaceMapInner as f,
|
|
594
617
|
memoize as m
|
|
595
618
|
};
|
|
@@ -11,7 +11,8 @@ const AmapMarker = defineSetup("AmapMarker", function(props, { emit }) {
|
|
|
11
11
|
const mapRef = useAmap();
|
|
12
12
|
onMounted(() => {
|
|
13
13
|
referenceCount.add();
|
|
14
|
-
|
|
14
|
+
const { registerOverlay: registerOverlay2, onClick, ...option } = props;
|
|
15
|
+
markerRef.value = new AMap.Marker({ ...option });
|
|
15
16
|
});
|
|
16
17
|
useMapOverlay({ registerOverlay, overlayRef: markerRef });
|
|
17
18
|
onUnmounted(() => {
|
|
@@ -11,7 +11,7 @@ const GmapAdvancedMarkerElement = defineSetup(
|
|
|
11
11
|
const mapRef = useGmap();
|
|
12
12
|
const handleGmpClick = (name) => emit(name, { target: markerRef.value });
|
|
13
13
|
onMounted(() => {
|
|
14
|
-
const { registerOverlay: registerOverlay2, ...markerViewProps } = props;
|
|
14
|
+
const { registerOverlay: registerOverlay2, onClick, ...markerViewProps } = props;
|
|
15
15
|
markerRef.value = new google.maps.marker.AdvancedMarkerElement({ ...markerViewProps });
|
|
16
16
|
});
|
|
17
17
|
onUnmounted(() => {
|
|
@@ -21,16 +21,13 @@ 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;
|
|
32
29
|
if (name === "readyPromise")
|
|
33
|
-
return readyPromise;
|
|
30
|
+
return payload.readyPromise;
|
|
34
31
|
return Reflect.get(target, name, receiver);
|
|
35
32
|
}
|
|
36
33
|
});
|
|
@@ -67,7 +64,7 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
|
67
64
|
const handleResize = () => emit("resize");
|
|
68
65
|
loadTraditionalChineseConvertOnce(payload.language === "zh-TW");
|
|
69
66
|
return () => {
|
|
70
|
-
var _a, _b, _c, _d, _e, _f
|
|
67
|
+
var _a, _b, _c, _d, _e, _f;
|
|
71
68
|
const {
|
|
72
69
|
supplier,
|
|
73
70
|
gmapId,
|
|
@@ -82,12 +79,16 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
|
82
79
|
touchEnable = true,
|
|
83
80
|
touchZoomCenter
|
|
84
81
|
} = props;
|
|
85
|
-
if (status === Status.LOADING)
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
if (status === Status.LOADING) {
|
|
83
|
+
const node = (_a = slots.loading) == null ? void 0 : _a.call(slots);
|
|
84
|
+
return node ? h("div", [node]) : h(Loading);
|
|
85
|
+
}
|
|
86
|
+
if (status === Status.FAILURE) {
|
|
87
|
+
const node = (_b = slots.fallback) == null ? void 0 : _b.call(slots);
|
|
88
|
+
return node ? h("div", [node]) : h(Loading);
|
|
89
|
+
}
|
|
90
|
+
const children = (_c = slots.default) == null ? void 0 : _c.call(slots);
|
|
91
|
+
const outArea = (_d = slots.outerArea) == null ? void 0 : _d.call(slots);
|
|
91
92
|
const mapId = patchGmapIdForAlipayCompatible({
|
|
92
93
|
gmapId,
|
|
93
94
|
gmapRasterId,
|
|
@@ -97,7 +98,7 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
|
97
98
|
switch (supplier) {
|
|
98
99
|
case "gmap":
|
|
99
100
|
return h("div", {
|
|
100
|
-
"class": `${heycarMap} ${(
|
|
101
|
+
"class": `${heycarMap} ${(_e = attrs.class) != null ? _e : ""}`,
|
|
101
102
|
"attrs": {
|
|
102
103
|
"lang": language
|
|
103
104
|
},
|
|
@@ -128,7 +129,7 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
|
|
|
128
129
|
}), outArea]);
|
|
129
130
|
default:
|
|
130
131
|
return h("div", {
|
|
131
|
-
"class": `${heycarMap} ${(
|
|
132
|
+
"class": `${heycarMap} ${(_f = attrs.class) != null ? _f : ""}`,
|
|
132
133
|
"attrs": {
|
|
133
134
|
"lang": language
|
|
134
135
|
},
|
|
@@ -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";
|
|
@@ -1,7 +1,7 @@
|
|
|
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"];
|
|
@@ -25,20 +25,22 @@ export interface AmapLoaderProps extends Pick<GmapLoaderProps, "fallback" | "loa
|
|
|
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>;
|
|
31
32
|
readyPromise: Promise<undefined>;
|
|
32
33
|
};
|
|
33
34
|
export interface GmapLoaderProps extends LoaderOptions {
|
|
35
|
+
disableRef?: Ref<boolean>;
|
|
34
36
|
/**
|
|
35
37
|
* Render prop used to switch to loading component.
|
|
36
38
|
*/
|
|
37
|
-
loading?: () =>
|
|
39
|
+
loading?: () => VNodeChild;
|
|
38
40
|
/**
|
|
39
41
|
* Render prop used to switch to error fallback component.
|
|
40
42
|
*/
|
|
41
|
-
fallback?: () =>
|
|
43
|
+
fallback?: () => VNodeChild;
|
|
42
44
|
/**
|
|
43
45
|
* Callback prop used to access `@googlemaps/js-api-loader` and `Status`.
|
|
44
46
|
*
|
|
@@ -551,7 +551,7 @@ var Status = /* @__PURE__ */ ((Status2) => {
|
|
|
551
551
|
return Status2;
|
|
552
552
|
})(Status || {});
|
|
553
553
|
const useAmapLoader = (props) => {
|
|
554
|
-
const { onChange } = props;
|
|
554
|
+
const { disableRef, onChange } = props;
|
|
555
555
|
let resolveLoader;
|
|
556
556
|
let rejectLoader;
|
|
557
557
|
const readyPromise = new Promise((resolve, reject) => {
|
|
@@ -567,8 +567,10 @@ const useAmapLoader = (props) => {
|
|
|
567
567
|
return { ...options, key: apiKey, version: version != null ? version : "2.0" };
|
|
568
568
|
});
|
|
569
569
|
watchPostEffectForDeepOption(
|
|
570
|
-
() => optionsRef.value,
|
|
571
|
-
(options) => {
|
|
570
|
+
() => [optionsRef.value, disableRef == null ? void 0 : disableRef.value],
|
|
571
|
+
([options, disable]) => {
|
|
572
|
+
if (disable)
|
|
573
|
+
return;
|
|
572
574
|
const setStatusAndExecuteCallback = (status) => {
|
|
573
575
|
statusRef.value = status;
|
|
574
576
|
if (status === "SUCCESS")
|
|
@@ -603,7 +605,7 @@ const loadGmapOnce = createRunOnce((opts) => {
|
|
|
603
605
|
return loader.load();
|
|
604
606
|
});
|
|
605
607
|
const useGmapLoader = (props) => {
|
|
606
|
-
const { onChange } = props;
|
|
608
|
+
const { disableRef, onChange } = props;
|
|
607
609
|
let resolveLoader;
|
|
608
610
|
let rejectLoader;
|
|
609
611
|
const readyPromise = new Promise((resolve, reject) => {
|
|
@@ -619,8 +621,10 @@ const useGmapLoader = (props) => {
|
|
|
619
621
|
return options;
|
|
620
622
|
});
|
|
621
623
|
watchPostEffectForDeepOption(
|
|
622
|
-
() => optionsRef.value,
|
|
623
|
-
(options) => {
|
|
624
|
+
() => [optionsRef.value, disableRef == null ? void 0 : disableRef.value],
|
|
625
|
+
([options, disable]) => {
|
|
626
|
+
if (disable)
|
|
627
|
+
return;
|
|
624
628
|
const language = navigator.language;
|
|
625
629
|
const setStatusAndExecuteCallback = (status) => {
|
|
626
630
|
statusRef.value = status;
|
|
@@ -649,22 +653,33 @@ const useGmapLoader = (props) => {
|
|
|
649
653
|
return { statusRef, readyPromise };
|
|
650
654
|
};
|
|
651
655
|
const useMapLoader = (props) => {
|
|
652
|
-
const { gmapKey, amapKey, amapSecret, amapServiceHost,
|
|
653
|
-
|
|
656
|
+
const { gmapKey, amapKey, amapSecret, amapServiceHost, language, onChange } = props;
|
|
657
|
+
const { statusRef: amapStatusRef, readyPromise: amapReadyPromise } = useAmapLoader({
|
|
658
|
+
apiKey: amapKey,
|
|
659
|
+
apiSecret: amapSecret,
|
|
660
|
+
apiServiceHost: amapServiceHost,
|
|
661
|
+
plugins: DEFAULT_AMAP_PLUGINS,
|
|
662
|
+
disableRef: computed(() => props.supplier !== "amap"),
|
|
663
|
+
onChange
|
|
664
|
+
});
|
|
665
|
+
const { statusRef: gmapStatusRef, readyPromise: gmapReadyPromise } = useGmapLoader({
|
|
654
666
|
apiKey: gmapKey,
|
|
655
667
|
language,
|
|
656
668
|
version: "weekly",
|
|
657
669
|
// todo: 需要提前设置 region
|
|
658
670
|
// region: "CN",
|
|
659
671
|
libraries: DEFAULT_GMAP_LIBRARIES,
|
|
660
|
-
|
|
661
|
-
}) : useAmapLoader({
|
|
662
|
-
apiKey: amapKey,
|
|
663
|
-
apiSecret: amapSecret,
|
|
664
|
-
apiServiceHost: amapServiceHost,
|
|
665
|
-
plugins: DEFAULT_AMAP_PLUGINS,
|
|
672
|
+
disableRef: computed(() => props.supplier !== "gmap"),
|
|
666
673
|
onChange
|
|
667
674
|
});
|
|
675
|
+
return {
|
|
676
|
+
get statusRef() {
|
|
677
|
+
return props.supplier === "gmap" ? gmapStatusRef : amapStatusRef;
|
|
678
|
+
},
|
|
679
|
+
get readyPromise() {
|
|
680
|
+
return props.supplier === "gmap" ? gmapReadyPromise : amapReadyPromise;
|
|
681
|
+
}
|
|
682
|
+
};
|
|
668
683
|
};
|
|
669
684
|
export {
|
|
670
685
|
DEFAULT_AMAP_PLUGINS,
|