@heycar/heycars-map 2.8.2 → 2.10.0
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 +6 -3
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +4 -1
- package/dist/v2/Demo/DemoBusinessReselectPlace.js +4 -1
- package/dist/v2/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.d.ts +3 -0
- package/dist/v2/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +6 -1
- package/dist/v2/business-components/AbsoluteAddressBox/AbsoluteAddressBox.js +24 -14
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +4 -1
- package/dist/v2/css/{AbsoluteAddressBox-ea4f4761.css → AbsoluteAddressBox-7502ed45.css} +31 -6
- package/dist/v2/types/global.d.ts +1 -0
- package/dist/v2/utils/compatibleWatchPosition.js +9 -3
- package/dist/v2/utils/log.js +1 -1
- package/dist/v2/utils/transform.d.ts +1 -0
- package/dist/v2/utils/transform.js +10 -0
- package/dist/v2/utils/typeChecking.d.ts +9 -0
- package/dist/v2/utils/typeChecking.js +58 -0
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +4 -1
- package/dist/v3/Demo/DemoBusinessReselectPlace.js +4 -1
- package/dist/v3/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.d.ts +3 -0
- package/dist/v3/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +6 -1
- package/dist/v3/business-components/AbsoluteAddressBox/AbsoluteAddressBox.js +22 -14
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +4 -3
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +0 -2
- package/dist/v3/css/{AbsoluteAddressBox-ea4f4761.css → AbsoluteAddressBox-7502ed45.css} +31 -6
- package/dist/v3/types/global.d.ts +1 -0
- package/dist/v3/utils/compatibleWatchPosition.js +9 -3
- package/dist/v3/utils/log.js +1 -1
- package/dist/v3/utils/transform.d.ts +1 -0
- package/dist/v3/utils/transform.js +10 -0
- package/dist/v3/utils/typeChecking.d.ts +9 -0
- package/dist/v3/utils/typeChecking.js +58 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -263,11 +263,14 @@ export default defineComponent({
|
|
|
263
263
|
getRecomendPlace={getRecomendPlace}
|
|
264
264
|
getDefaultCenterPlace={getDefaultCenterPlace}
|
|
265
265
|
renderPlacePhoto={(place) => {
|
|
266
|
-
|
|
267
|
-
return
|
|
266
|
+
// or return;
|
|
267
|
+
return {
|
|
268
|
+
title: "图文引导",
|
|
269
|
+
src: "https://oss-now.heycars.cn/image/graphicGuidance/file/hmlh38_xs6_DdksNX0_TbgF0lKXp.jpg",
|
|
270
|
+
};
|
|
268
271
|
}}
|
|
269
272
|
renderPlaceTag={(place) => {
|
|
270
|
-
|
|
273
|
+
// or return;
|
|
271
274
|
return "最近使用";
|
|
272
275
|
}}
|
|
273
276
|
mapContext={mapContext}
|
|
@@ -127,7 +127,10 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
|
|
|
127
127
|
"getAvailable": () => Promise.resolve(true),
|
|
128
128
|
"getRecomendPlace": getRecomendPlace,
|
|
129
129
|
"renderPlacePhoto": (place) => {
|
|
130
|
-
return
|
|
130
|
+
return {
|
|
131
|
+
title: "图文引导",
|
|
132
|
+
src: "https://oss-now.heycars.cn/image/graphicGuidance/file/hmlh38_xs6_DdksNX0_TbgF0lKXp.jpg"
|
|
133
|
+
};
|
|
131
134
|
},
|
|
132
135
|
"renderPlaceTag": (place) => {
|
|
133
136
|
return "最近使用";
|
|
@@ -131,7 +131,10 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
|
|
|
131
131
|
"getAvailable": () => Promise.resolve(true),
|
|
132
132
|
"getRecomendPlace": getRecomendPlace,
|
|
133
133
|
"renderPlacePhoto": (place) => {
|
|
134
|
-
return
|
|
134
|
+
return {
|
|
135
|
+
title: "图文引导",
|
|
136
|
+
src: "https://oss-now.heycars.cn/image/graphicGuidance/file/hmlh38_xs6_DdksNX0_TbgF0lKXp.jpg"
|
|
137
|
+
};
|
|
135
138
|
},
|
|
136
139
|
"renderPlaceTag": (place) => {
|
|
137
140
|
return "最近使用";
|
|
@@ -15,6 +15,9 @@ export declare const boxTextLayout: import("@vanilla-extract/recipes").RuntimeFn
|
|
|
15
15
|
}>;
|
|
16
16
|
export declare const boxPhotoLayout: string;
|
|
17
17
|
export declare const boxPhoto: string;
|
|
18
|
+
export declare const boxPhotoDescriptionLayout: string;
|
|
19
|
+
export declare const boxPhotoArrow: string;
|
|
20
|
+
export declare const boxPhotoDescription: string;
|
|
18
21
|
export declare const boxPhotoIcon: string;
|
|
19
22
|
export declare const boxTitle: string;
|
|
20
23
|
export declare const boxDescription: string;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
interface AddressBoxPhoto {
|
|
2
|
+
src: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
}
|
|
1
5
|
export interface AbsoluteAddressBoxProps {
|
|
2
6
|
type: "box" | "locator" | "loading";
|
|
3
7
|
title: string;
|
|
4
8
|
description?: string;
|
|
5
|
-
photo?:
|
|
9
|
+
photo?: AddressBoxPhoto;
|
|
6
10
|
withArrow?: boolean;
|
|
7
11
|
onClickText?: () => any;
|
|
8
12
|
onClickPhoto?: () => any;
|
|
9
13
|
}
|
|
10
14
|
export declare const AbsoluteAddressBox: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<AbsoluteAddressBoxProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<AbsoluteAddressBoxProps, Required<AbsoluteAddressBoxProps>>, "clickText" | "clickPhoto", AbsoluteAddressBoxProps>;
|
|
15
|
+
export {};
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import "../../css/AbsoluteAddressBox-
|
|
1
|
+
import "../../css/AbsoluteAddressBox-7502ed45.css";
|
|
2
2
|
import { h } from "vue";
|
|
3
3
|
import { computed } from "vue-demi";
|
|
4
|
-
import { ICON_DOT_LOADING_URL
|
|
4
|
+
import { ICON_DOT_LOADING_URL } from "../../api/cdn.js";
|
|
5
5
|
import { i as imgAddressLocator } from "../../chunks/address-locator.98305e58.js";
|
|
6
6
|
import { i as imgArrowRight } from "../../chunks/arrow-right.eedc7433.js";
|
|
7
7
|
import { defineSetup } from "../../types/helper.js";
|
|
8
8
|
import { c as createRuntimeFn } from "../../chunks/vanilla-extract-recipes-createRuntimeFn.esm.bd6fc290.js";
|
|
9
9
|
const imgBubbleRightArc = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTAgMGgyLjEzMWExMCAxMCAwIDAxOS42OTYgNy41NTJMMTggMzJILjA0MkwwIDB6IiBmaWxsPSIjMjUzRTdBIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=";
|
|
10
|
+
const imgGuideArrow = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHdpZHRoPSIyIiBoZWlnaHQ9IjYiPgogIDxwYXRoIGQ9Ik0uNTE2IDEuMTAzQS4zLjMgMCAwMDAgMS4zMXYyLjY2OGEuMy4zIDAgMDAuNTE2LjIwOEwxLjggMi44NTNhLjMuMyAwIDAwMC0uNDE2TC41MTYgMS4xMDN6IiBmaWxsPSIjRkZGIiAvPgo8L3N2Zz4=";
|
|
10
11
|
const AbsoluteAddressBox_css_ts_vanilla = "";
|
|
11
12
|
var absoluteAddressBox = "n8tgem1";
|
|
12
13
|
var absoluteAddressBoxLayout = "n8tgem0";
|
|
13
|
-
var arrowRight = "
|
|
14
|
+
var arrowRight = "n8tgemj";
|
|
14
15
|
var boxBody = "n8tgem2";
|
|
15
16
|
var boxHeader = "n8tgem3";
|
|
16
17
|
var boxHeaderIcon = "n8tgem4";
|
|
17
18
|
var boxHeaderText = "n8tgem5";
|
|
18
19
|
var boxPhoto = "n8tgemb";
|
|
19
|
-
var
|
|
20
|
+
var boxPhotoArrow = "n8tgemd";
|
|
21
|
+
var boxPhotoDescription = "n8tgeme";
|
|
22
|
+
var boxPhotoDescriptionLayout = "n8tgemc";
|
|
20
23
|
var boxPhotoLayout = "n8tgema";
|
|
21
24
|
var boxTextClickableArea = "n8tgem6";
|
|
22
25
|
var boxTextLayout = createRuntimeFn({ defaultClassName: "n8tgem7", variantClassNames: { withArrow: { true: "n8tgem8", false: "n8tgem9" } }, defaultVariants: {}, compoundVariants: [] });
|
|
23
|
-
var boxTitle = "
|
|
24
|
-
var imgDotLoading = "
|
|
25
|
-
var locatorIcon = "
|
|
26
|
-
var straightLine = "
|
|
26
|
+
var boxTitle = "n8tgemg";
|
|
27
|
+
var imgDotLoading = "n8tgemi";
|
|
28
|
+
var locatorIcon = "n8tgeml";
|
|
29
|
+
var straightLine = "n8tgemk";
|
|
27
30
|
const MultilineTitle = defineSetup("MultilineTitle", function(props, {
|
|
28
31
|
attrs
|
|
29
32
|
}) {
|
|
@@ -88,22 +91,29 @@ const AbsoluteAddressBox = defineSetup("AbsoluteAddressBox", function(props, {
|
|
|
88
91
|
}
|
|
89
92
|
})]), h("div", {
|
|
90
93
|
"class": boxBody
|
|
91
|
-
}, [!!photo && h("div", {
|
|
94
|
+
}, [!!(photo == null ? void 0 : photo.src) && h("div", {
|
|
92
95
|
"class": boxPhotoLayout
|
|
93
96
|
}, [h("img", {
|
|
94
97
|
"class": boxPhoto,
|
|
95
98
|
"attrs": {
|
|
96
|
-
"src": photo
|
|
99
|
+
"src": photo.src
|
|
97
100
|
},
|
|
98
101
|
"on": {
|
|
99
102
|
"click": handleClickPhoto
|
|
100
103
|
}
|
|
101
|
-
}), h("
|
|
102
|
-
"class":
|
|
104
|
+
}), !!photo.title && h("div", {
|
|
105
|
+
"class": boxPhotoDescriptionLayout,
|
|
106
|
+
"on": {
|
|
107
|
+
"click": handleClickPhoto
|
|
108
|
+
}
|
|
109
|
+
}, [h("div", {
|
|
110
|
+
"class": boxPhotoDescription
|
|
111
|
+
}, [photo.title]), h("img", {
|
|
112
|
+
"class": boxPhotoArrow,
|
|
103
113
|
"attrs": {
|
|
104
|
-
"src":
|
|
114
|
+
"src": imgGuideArrow
|
|
105
115
|
}
|
|
106
|
-
})]), h("div", {
|
|
116
|
+
})])]), h("div", {
|
|
107
117
|
"class": boxTextClickableArea,
|
|
108
118
|
"on": {
|
|
109
119
|
"click": handleClickText
|
|
@@ -33,7 +33,10 @@ export interface BusinessRecomendPlaceMapProps extends CoordinatifyProps<Omit<He
|
|
|
33
33
|
geoErrorOnceNotificationKey?: string;
|
|
34
34
|
mapContext: CoordinatifyProps<BusinessRecomendPlaceContext>;
|
|
35
35
|
defaultCenterPlace?: CoordinatePlace | ((place?: CoordinatePlace) => CoordinatePlace | undefined);
|
|
36
|
-
renderPlacePhoto?: (place: CoordinatePlace) =>
|
|
36
|
+
renderPlacePhoto?: (place: CoordinatePlace) => undefined | {
|
|
37
|
+
src: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
};
|
|
37
40
|
renderPlaceTag?: PickupPointsProps["renderPlaceTag"];
|
|
38
41
|
onLoadGeoLocation?: Coordinatify<UseGeoLocationProps["onLoad"]>;
|
|
39
42
|
onLoadDefaultGeoLocation?: Coordinatify<UseGeoLocationProps["onLoadDefault"]>;
|
|
@@ -69,6 +69,31 @@
|
|
|
69
69
|
height: 100%;
|
|
70
70
|
}
|
|
71
71
|
.n8tgemc {
|
|
72
|
+
position: absolute;
|
|
73
|
+
bottom: 0;
|
|
74
|
+
left: 0;
|
|
75
|
+
right: 0;
|
|
76
|
+
height: 3.6vw;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
display: flex;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
align-items: center;
|
|
81
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
82
|
+
}
|
|
83
|
+
.n8tgemd {
|
|
84
|
+
margin-left: 0.6vw;
|
|
85
|
+
margin-top: 0.2vw;
|
|
86
|
+
width: 0.6vw;
|
|
87
|
+
height: 1.8vw;
|
|
88
|
+
}
|
|
89
|
+
.n8tgeme {
|
|
90
|
+
font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
font-size: 2.1vw;
|
|
93
|
+
color: #FFFFFF;
|
|
94
|
+
line-height: 1;
|
|
95
|
+
}
|
|
96
|
+
.n8tgemf {
|
|
72
97
|
pointer-events: none;
|
|
73
98
|
position: absolute;
|
|
74
99
|
right: 0.045vw;
|
|
@@ -76,7 +101,7 @@
|
|
|
76
101
|
width: 3.74vw;
|
|
77
102
|
height: 3.74vw;
|
|
78
103
|
}
|
|
79
|
-
.
|
|
104
|
+
.n8tgemg {
|
|
80
105
|
display: -webkit-box;
|
|
81
106
|
font-size: 3.47vw;
|
|
82
107
|
font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_SEMI_BOLD);
|
|
@@ -87,7 +112,7 @@
|
|
|
87
112
|
-webkit-box-orient: vertical;
|
|
88
113
|
overflow: hidden;
|
|
89
114
|
}
|
|
90
|
-
.
|
|
115
|
+
.n8tgemh {
|
|
91
116
|
margin-top: 0.53vw;
|
|
92
117
|
font-size: 2.93vw;
|
|
93
118
|
font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
|
|
@@ -96,22 +121,22 @@
|
|
|
96
121
|
line-height: 4.27vw;
|
|
97
122
|
opacity: 0.8;
|
|
98
123
|
}
|
|
99
|
-
.
|
|
124
|
+
.n8tgemi {
|
|
100
125
|
margin: 1.865vw 0;
|
|
101
126
|
width: 7.467vw;
|
|
102
127
|
height: 1.6vw;
|
|
103
128
|
}
|
|
104
|
-
.
|
|
129
|
+
.n8tgemj {
|
|
105
130
|
width: 1.758vw;
|
|
106
131
|
height: 2.93vw;
|
|
107
132
|
}
|
|
108
|
-
.
|
|
133
|
+
.n8tgemk {
|
|
109
134
|
width: 0.8vw;
|
|
110
135
|
height: 4vw;
|
|
111
136
|
background: #4C80FF;
|
|
112
137
|
border-radius: 0vw 0vw 26.67vw 26.67vw;
|
|
113
138
|
}
|
|
114
|
-
.
|
|
139
|
+
.n8tgeml {
|
|
115
140
|
width: 6.9355vw;
|
|
116
141
|
height: 10.67vw;
|
|
117
142
|
}
|
|
@@ -5,6 +5,7 @@ import { createReadOnce, sleep, createRunOnce } from "./helper.js";
|
|
|
5
5
|
import { detectBrowserPlatform, BRWOSER_PLATFORM, OS_PLATFORM, detectAlipayWallet, ALIPAY_WALLET, detectOSPlatform } from "./platform.js";
|
|
6
6
|
import { QueryWxSignatureStatus } from "./QueryWxSignatureStatus.js";
|
|
7
7
|
import { isGeoPositionEqual, alipayMyGetLocationSuccessResponse2GeolocationPosition, alipayMyGetLocationError2GeolocationPositionErrorCode, wxGetLocationSuccessResponse2GeolocationPosition } from "./transform.js";
|
|
8
|
+
import { toGeolocationGetCurrentPosition } from "./typeChecking.js";
|
|
8
9
|
const WX_INITIAL_GET_LOCATION_TIME_RATIO = 4;
|
|
9
10
|
const WX_SIGNATURE_TIMEOUT = 20 * 1e3;
|
|
10
11
|
const WX_GET_LOCATION_INTERVAL = 1 * 1e3;
|
|
@@ -200,7 +201,7 @@ const apGetLocation = ({ type, cacheTimeout, success, fail }) => {
|
|
|
200
201
|
const apType = type >= 2 ? 0 : type === 0 ? 2 : 1;
|
|
201
202
|
ap.getLocation({ type: apType, cacheTimeout }).then(success).catch(fail);
|
|
202
203
|
};
|
|
203
|
-
function androidWatchPosition(onSuccess, onError, option) {
|
|
204
|
+
function androidWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
204
205
|
let enable = true;
|
|
205
206
|
let prevGeoPosition = void 0;
|
|
206
207
|
let geoErrorMessage = void 0;
|
|
@@ -213,7 +214,7 @@ function androidWatchPosition(onSuccess, onError, option) {
|
|
|
213
214
|
}
|
|
214
215
|
const geoPosition = await new Promise((resolve) => {
|
|
215
216
|
let isHandled = false;
|
|
216
|
-
|
|
217
|
+
getLocationFn(
|
|
217
218
|
function onSuccess2(geoLocationPosition) {
|
|
218
219
|
if (isHandled)
|
|
219
220
|
return;
|
|
@@ -290,7 +291,12 @@ function compatibleWathPosition(onSuccess, onError, option) {
|
|
|
290
291
|
if (browserPlatform === BRWOSER_PLATFORM.ALIPAY || browserPlatform == BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM) {
|
|
291
292
|
return alipayWatchPosition(onSuccess, onError, option, (props) => my.getLocation(props));
|
|
292
293
|
}
|
|
293
|
-
return androidWatchPosition(onSuccess, onError, option)
|
|
294
|
+
return androidWatchPosition(onSuccess, onError, option, (...args) => {
|
|
295
|
+
return typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function" ? toGeolocationGetCurrentPosition(
|
|
296
|
+
HEYCAR_GEOLOCATION_GET_CURRENT_POSITION,
|
|
297
|
+
"HEYCAR_GEOLOCATION_GET_CURRENT_POSITION"
|
|
298
|
+
)(...args) : navigator.geolocation.getCurrentPosition(...args);
|
|
299
|
+
});
|
|
294
300
|
}
|
|
295
301
|
function compatibleGeoPositionTransform(position, transform) {
|
|
296
302
|
const platform = detectBrowserPlatform();
|
package/dist/v2/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.
|
|
3
|
+
const pkgVersion = "2.10.0";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -48,4 +48,5 @@ export declare const signal2promise: (signal?: AbortSignal) => Promise<any>;
|
|
|
48
48
|
export declare const googleEncodedPolyline2googleLatLng: (value: string) => google.maps.LatLng[];
|
|
49
49
|
export declare const gaodePolyline2amapLngLat: (value: string) => AMap.LngLat[];
|
|
50
50
|
export declare const amapTraffic2trafficStatus: (value?: AMap.TMC["status"]) => TrafficStatus;
|
|
51
|
+
export declare const error2beautifyString: (error: unknown) => string;
|
|
51
52
|
export {};
|
|
@@ -306,6 +306,15 @@ const amapTraffic2trafficStatus = (value) => {
|
|
|
306
306
|
return "HEAVY_TRAFFIC_JAM";
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
|
+
const error2beautifyString = (error) => {
|
|
310
|
+
if (typeof error === "string")
|
|
311
|
+
return error;
|
|
312
|
+
if (error instanceof GeolocationPositionError) {
|
|
313
|
+
const { code, message } = error;
|
|
314
|
+
return `GeolocationPositionError: code: ${code}, message: ${message}`;
|
|
315
|
+
}
|
|
316
|
+
return JSON.stringify(error, Object.getOwnPropertyNames(error), 2).replace(/\\n/g, "\n").replace(/\\"/g, '"');
|
|
317
|
+
};
|
|
309
318
|
export {
|
|
310
319
|
alipayMyGetLocationError2GeolocationPositionErrorCode,
|
|
311
320
|
alipayMyGetLocationSuccessResponse2GeolocationPosition,
|
|
@@ -316,6 +325,7 @@ export {
|
|
|
316
325
|
decodeAsterisk,
|
|
317
326
|
deltaZoom2animationDuration,
|
|
318
327
|
distanceVw2animationDuration,
|
|
328
|
+
error2beautifyString,
|
|
319
329
|
gaodePointsStringify,
|
|
320
330
|
gaodePolyline2amapLngLat,
|
|
321
331
|
geoPositionError2businessTimeout,
|
|
@@ -42,4 +42,13 @@ interface MaybeCoordinateTrackPoint {
|
|
|
42
42
|
}
|
|
43
43
|
export declare const toCoordinateTrackPoint: (value?: MaybeCoordinateTrackPoint) => CoordinateTrackPoint;
|
|
44
44
|
export declare function isProxyServiceError(error: unknown): error is ProxyServiceError;
|
|
45
|
+
export declare function toGeolocationPositionError(error: unknown, prefix?: string): GeolocationPositionError;
|
|
46
|
+
/**
|
|
47
|
+
* @warning: 目前只用到
|
|
48
|
+
* * GeolocationPosition.coords.latitude
|
|
49
|
+
* * GeolocationPosition.coords.longitude
|
|
50
|
+
* 如果将来用到其他属性,需要修补充
|
|
51
|
+
*/
|
|
52
|
+
export declare function assertGeolocationPosition(position: unknown): asserts position is GeolocationPosition;
|
|
53
|
+
export declare function toGeolocationGetCurrentPosition(fn: Geolocation["getCurrentPosition"], fnName?: string): Geolocation["getCurrentPosition"];
|
|
45
54
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { error2beautifyString } from "./transform.js";
|
|
1
2
|
const createTypeError = (typeName, value, detail) => {
|
|
2
3
|
if (detail)
|
|
3
4
|
return new Error(
|
|
@@ -109,7 +110,62 @@ const toCoordinateTrackPoint = (value) => {
|
|
|
109
110
|
function isProxyServiceError(error) {
|
|
110
111
|
return !!error && typeof error === "object" && "msg" in error && "code" in error;
|
|
111
112
|
}
|
|
113
|
+
function toGeolocationPositionError(error, prefix = "") {
|
|
114
|
+
if (error instanceof GeolocationPositionError)
|
|
115
|
+
return error;
|
|
116
|
+
if (typeof error === "object" && error !== null && "code" in error && (error.code === 1 || error.code === 2 || error.code === 3) && "message" in error && typeof error.message === "string") {
|
|
117
|
+
return error;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
code: 2,
|
|
121
|
+
message: prefix + `GeolocationPositionError 格式错误, origin error:
|
|
122
|
+
${error2beautifyString(error)}`
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function assertGeolocationPosition(position) {
|
|
126
|
+
if (position instanceof GeolocationPosition)
|
|
127
|
+
return;
|
|
128
|
+
if (typeof position !== "object" || position === null)
|
|
129
|
+
throw Error("GeolocationPosition 格式错误, 应当是一个非 null 的 object");
|
|
130
|
+
if (!("coords" in position) || typeof position.coords !== "object" || position.coords === null)
|
|
131
|
+
throw Error("GeolocationPosition 格式错误, coords 应当是非 null 的 object");
|
|
132
|
+
if (!("latitude" in position.coords) || typeof position.coords.latitude !== "number")
|
|
133
|
+
throw Error("GeolocationPosition 格式错误, latitude 应当是 number");
|
|
134
|
+
if (!("longitude" in position.coords) || typeof position.coords.longitude !== "number")
|
|
135
|
+
throw Error("GeolocationPosition 格式错误, longitude 应当是 number");
|
|
136
|
+
}
|
|
137
|
+
function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
|
|
138
|
+
const prefix = "ASSERT_GEOLOCATION_GET_CURRENT_POSITION_ERROR\n";
|
|
139
|
+
if (typeof fn !== "function")
|
|
140
|
+
throw Error(prefix + "Geolocation.getCurrentPosition 类型必须是一个 function");
|
|
141
|
+
return function assertedGetCurrentPosition(onSuccess, onError, options) {
|
|
142
|
+
const asseertedOnSuccess = (position) => {
|
|
143
|
+
try {
|
|
144
|
+
assertGeolocationPosition(position);
|
|
145
|
+
} catch (err) {
|
|
146
|
+
const { message } = err;
|
|
147
|
+
onError({
|
|
148
|
+
code: 2,
|
|
149
|
+
message: prefix + `${fnName} onSuccess 回调错误: ${message}`
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
onSuccess(position);
|
|
154
|
+
};
|
|
155
|
+
const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
|
|
156
|
+
try {
|
|
157
|
+
fn(asseertedOnSuccess, asseertedOnError, options);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
onError({
|
|
160
|
+
code: 2,
|
|
161
|
+
message: prefix + `${fnName} 运行异常:
|
|
162
|
+
${error2beautifyString(err)}`
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
112
167
|
export {
|
|
168
|
+
assertGeolocationPosition,
|
|
113
169
|
assertNoConflictTypeAndZone,
|
|
114
170
|
createTypeError,
|
|
115
171
|
isCoordinatePoint,
|
|
@@ -121,5 +177,7 @@ export {
|
|
|
121
177
|
toCoordinateRecommendZonePlacesType,
|
|
122
178
|
toCoordinateTrackPoint,
|
|
123
179
|
toCoordinateZoneType,
|
|
180
|
+
toGeolocationGetCurrentPosition,
|
|
181
|
+
toGeolocationPositionError,
|
|
124
182
|
toRecommendType
|
|
125
183
|
};
|
|
@@ -126,7 +126,10 @@ const DemoBusinessRecomendPlace = defineSetup("DemoBusinessRecomendPlace", funct
|
|
|
126
126
|
"getAvailable": () => Promise.resolve(true),
|
|
127
127
|
"getRecomendPlace": getRecomendPlace,
|
|
128
128
|
"renderPlacePhoto": (place) => {
|
|
129
|
-
return
|
|
129
|
+
return {
|
|
130
|
+
title: "图文引导",
|
|
131
|
+
src: "https://oss-now.heycars.cn/image/graphicGuidance/file/hmlh38_xs6_DdksNX0_TbgF0lKXp.jpg"
|
|
132
|
+
};
|
|
130
133
|
},
|
|
131
134
|
"renderPlaceTag": (place) => {
|
|
132
135
|
return "最近使用";
|
|
@@ -130,7 +130,10 @@ const DemoBusinessReselectPlace = defineSetup("DemoBusinessReselectPlace", funct
|
|
|
130
130
|
"getAvailable": () => Promise.resolve(true),
|
|
131
131
|
"getRecomendPlace": getRecomendPlace,
|
|
132
132
|
"renderPlacePhoto": (place) => {
|
|
133
|
-
return
|
|
133
|
+
return {
|
|
134
|
+
title: "图文引导",
|
|
135
|
+
src: "https://oss-now.heycars.cn/image/graphicGuidance/file/hmlh38_xs6_DdksNX0_TbgF0lKXp.jpg"
|
|
136
|
+
};
|
|
134
137
|
},
|
|
135
138
|
"renderPlaceTag": (place) => {
|
|
136
139
|
return "最近使用";
|
|
@@ -15,6 +15,9 @@ export declare const boxTextLayout: import("@vanilla-extract/recipes").RuntimeFn
|
|
|
15
15
|
}>;
|
|
16
16
|
export declare const boxPhotoLayout: string;
|
|
17
17
|
export declare const boxPhoto: string;
|
|
18
|
+
export declare const boxPhotoDescriptionLayout: string;
|
|
19
|
+
export declare const boxPhotoArrow: string;
|
|
20
|
+
export declare const boxPhotoDescription: string;
|
|
18
21
|
export declare const boxPhotoIcon: string;
|
|
19
22
|
export declare const boxTitle: string;
|
|
20
23
|
export declare const boxDescription: string;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
interface AddressBoxPhoto {
|
|
2
|
+
src: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
}
|
|
1
5
|
export interface AbsoluteAddressBoxProps {
|
|
2
6
|
type: "box" | "locator" | "loading";
|
|
3
7
|
title: string;
|
|
4
8
|
description?: string;
|
|
5
|
-
photo?:
|
|
9
|
+
photo?: AddressBoxPhoto;
|
|
6
10
|
withArrow?: boolean;
|
|
7
11
|
onClickText?: () => any;
|
|
8
12
|
onClickPhoto?: () => any;
|
|
@@ -10,3 +14,4 @@ export interface AbsoluteAddressBoxProps {
|
|
|
10
14
|
export declare const AbsoluteAddressBox: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<AbsoluteAddressBoxProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<AbsoluteAddressBoxProps, Required<AbsoluteAddressBoxProps>>, "clickText" | "clickPhoto", import("vue-demi").PublicProps, AbsoluteAddressBoxProps, AbsoluteAddressBoxProps, import("vue-demi").SlotsType<{} & {
|
|
11
15
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
12
16
|
}>>;
|
|
17
|
+
export {};
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import "../../css/AbsoluteAddressBox-
|
|
1
|
+
import "../../css/AbsoluteAddressBox-7502ed45.css";
|
|
2
2
|
import { createVNode } from "vue";
|
|
3
3
|
import { computed } from "vue-demi";
|
|
4
|
-
import { ICON_DOT_LOADING_URL
|
|
4
|
+
import { ICON_DOT_LOADING_URL } from "../../api/cdn.js";
|
|
5
5
|
import { i as imgAddressLocator } from "../../chunks/address-locator.98305e58.js";
|
|
6
6
|
import { i as imgArrowRight } from "../../chunks/arrow-right.eedc7433.js";
|
|
7
7
|
import { defineSetup } from "../../types/helper.js";
|
|
8
8
|
import { c as createRuntimeFn } from "../../chunks/vanilla-extract-recipes-createRuntimeFn.esm.bd6fc290.js";
|
|
9
9
|
const imgBubbleRightArc = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0iTTAgMGgyLjEzMWExMCAxMCAwIDAxOS42OTYgNy41NTJMMTggMzJILjA0MkwwIDB6IiBmaWxsPSIjMjUzRTdBIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=";
|
|
10
|
+
const imgGuideArrow = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHdpZHRoPSIyIiBoZWlnaHQ9IjYiPgogIDxwYXRoIGQ9Ik0uNTE2IDEuMTAzQS4zLjMgMCAwMDAgMS4zMXYyLjY2OGEuMy4zIDAgMDAuNTE2LjIwOEwxLjggMi44NTNhLjMuMyAwIDAwMC0uNDE2TC41MTYgMS4xMDN6IiBmaWxsPSIjRkZGIiAvPgo8L3N2Zz4=";
|
|
10
11
|
const AbsoluteAddressBox_css_ts_vanilla = "";
|
|
11
12
|
var absoluteAddressBox = "n8tgem1";
|
|
12
13
|
var absoluteAddressBoxLayout = "n8tgem0";
|
|
13
|
-
var arrowRight = "
|
|
14
|
+
var arrowRight = "n8tgemj";
|
|
14
15
|
var boxBody = "n8tgem2";
|
|
15
16
|
var boxHeader = "n8tgem3";
|
|
16
17
|
var boxHeaderIcon = "n8tgem4";
|
|
17
18
|
var boxHeaderText = "n8tgem5";
|
|
18
19
|
var boxPhoto = "n8tgemb";
|
|
19
|
-
var
|
|
20
|
+
var boxPhotoArrow = "n8tgemd";
|
|
21
|
+
var boxPhotoDescription = "n8tgeme";
|
|
22
|
+
var boxPhotoDescriptionLayout = "n8tgemc";
|
|
20
23
|
var boxPhotoLayout = "n8tgema";
|
|
21
24
|
var boxTextClickableArea = "n8tgem6";
|
|
22
25
|
var boxTextLayout = createRuntimeFn({ defaultClassName: "n8tgem7", variantClassNames: { withArrow: { true: "n8tgem8", false: "n8tgem9" } }, defaultVariants: {}, compoundVariants: [] });
|
|
23
|
-
var boxTitle = "
|
|
24
|
-
var imgDotLoading = "
|
|
25
|
-
var locatorIcon = "
|
|
26
|
-
var straightLine = "
|
|
26
|
+
var boxTitle = "n8tgemg";
|
|
27
|
+
var imgDotLoading = "n8tgemi";
|
|
28
|
+
var locatorIcon = "n8tgeml";
|
|
29
|
+
var straightLine = "n8tgemk";
|
|
27
30
|
const MultilineTitle = defineSetup("MultilineTitle", function(props, {
|
|
28
31
|
attrs
|
|
29
32
|
}) {
|
|
@@ -80,16 +83,21 @@ const AbsoluteAddressBox = defineSetup("AbsoluteAddressBox", function(props, {
|
|
|
80
83
|
"src": imgBubbleRightArc
|
|
81
84
|
}, null)]), createVNode("div", {
|
|
82
85
|
"class": boxBody
|
|
83
|
-
}, [!!photo && createVNode("div", {
|
|
86
|
+
}, [!!(photo == null ? void 0 : photo.src) && createVNode("div", {
|
|
84
87
|
"class": boxPhotoLayout
|
|
85
88
|
}, [createVNode("img", {
|
|
86
89
|
"class": boxPhoto,
|
|
87
|
-
"src": photo,
|
|
90
|
+
"src": photo.src,
|
|
88
91
|
"onClick": handleClickPhoto
|
|
89
|
-
}, null), createVNode("
|
|
90
|
-
"class":
|
|
91
|
-
"
|
|
92
|
-
},
|
|
92
|
+
}, null), !!photo.title && createVNode("div", {
|
|
93
|
+
"class": boxPhotoDescriptionLayout,
|
|
94
|
+
"onClick": handleClickPhoto
|
|
95
|
+
}, [createVNode("div", {
|
|
96
|
+
"class": boxPhotoDescription
|
|
97
|
+
}, [photo.title]), createVNode("img", {
|
|
98
|
+
"class": boxPhotoArrow,
|
|
99
|
+
"src": imgGuideArrow
|
|
100
|
+
}, null)])]), createVNode("div", {
|
|
93
101
|
"class": boxTextClickableArea,
|
|
94
102
|
"onClick": handleClickText
|
|
95
103
|
}, [createVNode("div", {
|
|
@@ -33,7 +33,10 @@ export interface BusinessRecomendPlaceMapProps extends CoordinatifyProps<Omit<He
|
|
|
33
33
|
geoErrorOnceNotificationKey?: string;
|
|
34
34
|
mapContext: CoordinatifyProps<BusinessRecomendPlaceContext>;
|
|
35
35
|
defaultCenterPlace?: CoordinatePlace | ((place?: CoordinatePlace) => CoordinatePlace | undefined);
|
|
36
|
-
renderPlacePhoto?: (place: CoordinatePlace) =>
|
|
36
|
+
renderPlacePhoto?: (place: CoordinatePlace) => undefined | {
|
|
37
|
+
src: string;
|
|
38
|
+
title?: string;
|
|
39
|
+
};
|
|
37
40
|
renderPlaceTag?: PickupPointsProps["renderPlaceTag"];
|
|
38
41
|
onLoadGeoLocation?: Coordinatify<UseGeoLocationProps["onLoad"]>;
|
|
39
42
|
onLoadDefaultGeoLocation?: Coordinatify<UseGeoLocationProps["onLoadDefault"]>;
|
|
@@ -47,7 +50,6 @@ export interface BusinessRecomendPlaceMapProps extends CoordinatifyProps<Omit<He
|
|
|
47
50
|
onClickLocatorPhoto?: AbsoluteAddressBoxProps["onClickPhoto"];
|
|
48
51
|
}
|
|
49
52
|
export declare const BusinessRecomendPlaceMapInner: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessRecomendPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessRecomendPlaceMapProps, Required<BusinessRecomendPlaceMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessRecomendPlaceMapProps, BusinessRecomendPlaceMapProps, import("vue-demi").SlotsType<{
|
|
50
|
-
renderPlacePhoto?: ((place: CoordinatePlace) => string | undefined) | undefined;
|
|
51
53
|
renderPlaceTag?: PickupPointsProps["renderPlaceTag"];
|
|
52
54
|
fallback?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
53
55
|
loading?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
@@ -56,7 +58,6 @@ export declare const BusinessRecomendPlaceMapInner: import("vue-demi").DefineCom
|
|
|
56
58
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
57
59
|
}>>;
|
|
58
60
|
export declare const BusinessRecomendPlaceMap: import("vue-demi").DefineComponent<import("vue-demi").ComponentObjectPropsOptions<BusinessRecomendPlaceMapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<BusinessRecomendPlaceMapProps, Required<BusinessRecomendPlaceMapProps>>, "resize" | "dragEnd" | "zoomEnd" | "changePlace" | "loadGeoLocation" | "loadDefaultGeoLocation" | "changeByDrag" | "changeGeoLocation" | "changeRecomandPlace" | "geoError" | "geoErrorOnce" | "clickLocatorText" | "clickLocatorPhoto", import("vue-demi").PublicProps, BusinessRecomendPlaceMapProps, BusinessRecomendPlaceMapProps, import("vue-demi").SlotsType<{
|
|
59
|
-
renderPlacePhoto?: ((place: CoordinatePlace) => string | undefined) | undefined;
|
|
60
61
|
renderPlaceTag?: PickupPointsProps["renderPlaceTag"];
|
|
61
62
|
fallback?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
62
63
|
loading?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
@@ -7,7 +7,6 @@ export declare const BusinessReselectPlaceMapInner: import("vue-demi").DefineCom
|
|
|
7
7
|
fallback?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
8
8
|
loading?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
9
9
|
renderPlaceTag?: ((place: Place) => string | undefined) | undefined;
|
|
10
|
-
renderPlacePhoto?: ((place: CoordinatePlace) => string | undefined) | undefined;
|
|
11
10
|
} & {
|
|
12
11
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
13
12
|
}>>;
|
|
@@ -15,7 +14,6 @@ export declare const BusinessReselectPlaceMap: import("vue-demi").DefineComponen
|
|
|
15
14
|
fallback?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
16
15
|
loading?: (() => import("vue-demi").VNodeChild) | undefined;
|
|
17
16
|
renderPlaceTag?: ((place: Place) => string | undefined) | undefined;
|
|
18
|
-
renderPlacePhoto?: ((place: CoordinatePlace) => string | undefined) | undefined;
|
|
19
17
|
} & {
|
|
20
18
|
default?: import("../../demi-polyfill").Slot | undefined;
|
|
21
19
|
}>>;
|
|
@@ -69,6 +69,31 @@
|
|
|
69
69
|
height: 100%;
|
|
70
70
|
}
|
|
71
71
|
.n8tgemc {
|
|
72
|
+
position: absolute;
|
|
73
|
+
bottom: 0;
|
|
74
|
+
left: 0;
|
|
75
|
+
right: 0;
|
|
76
|
+
height: 3.6vw;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
display: flex;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
align-items: center;
|
|
81
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
82
|
+
}
|
|
83
|
+
.n8tgemd {
|
|
84
|
+
margin-left: 0.6vw;
|
|
85
|
+
margin-top: 0.2vw;
|
|
86
|
+
width: 0.6vw;
|
|
87
|
+
height: 1.8vw;
|
|
88
|
+
}
|
|
89
|
+
.n8tgeme {
|
|
90
|
+
font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
|
|
91
|
+
font-weight: 500;
|
|
92
|
+
font-size: 2.1vw;
|
|
93
|
+
color: #FFFFFF;
|
|
94
|
+
line-height: 1;
|
|
95
|
+
}
|
|
96
|
+
.n8tgemf {
|
|
72
97
|
pointer-events: none;
|
|
73
98
|
position: absolute;
|
|
74
99
|
right: 0.045vw;
|
|
@@ -76,7 +101,7 @@
|
|
|
76
101
|
width: 3.74vw;
|
|
77
102
|
height: 3.74vw;
|
|
78
103
|
}
|
|
79
|
-
.
|
|
104
|
+
.n8tgemg {
|
|
80
105
|
display: -webkit-box;
|
|
81
106
|
font-size: 3.47vw;
|
|
82
107
|
font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_SEMI_BOLD);
|
|
@@ -87,7 +112,7 @@
|
|
|
87
112
|
-webkit-box-orient: vertical;
|
|
88
113
|
overflow: hidden;
|
|
89
114
|
}
|
|
90
|
-
.
|
|
115
|
+
.n8tgemh {
|
|
91
116
|
margin-top: 0.53vw;
|
|
92
117
|
font-size: 2.93vw;
|
|
93
118
|
font-family: var(--HEYCAR_MAP_CSS_VAR_FONT_REGULAR);
|
|
@@ -96,22 +121,22 @@
|
|
|
96
121
|
line-height: 4.27vw;
|
|
97
122
|
opacity: 0.8;
|
|
98
123
|
}
|
|
99
|
-
.
|
|
124
|
+
.n8tgemi {
|
|
100
125
|
margin: 1.865vw 0;
|
|
101
126
|
width: 7.467vw;
|
|
102
127
|
height: 1.6vw;
|
|
103
128
|
}
|
|
104
|
-
.
|
|
129
|
+
.n8tgemj {
|
|
105
130
|
width: 1.758vw;
|
|
106
131
|
height: 2.93vw;
|
|
107
132
|
}
|
|
108
|
-
.
|
|
133
|
+
.n8tgemk {
|
|
109
134
|
width: 0.8vw;
|
|
110
135
|
height: 4vw;
|
|
111
136
|
background: #4C80FF;
|
|
112
137
|
border-radius: 0vw 0vw 26.67vw 26.67vw;
|
|
113
138
|
}
|
|
114
|
-
.
|
|
139
|
+
.n8tgeml {
|
|
115
140
|
width: 6.9355vw;
|
|
116
141
|
height: 10.67vw;
|
|
117
142
|
}
|
|
@@ -5,6 +5,7 @@ import { createReadOnce, sleep, createRunOnce } from "./helper.js";
|
|
|
5
5
|
import { detectBrowserPlatform, BRWOSER_PLATFORM, OS_PLATFORM, detectAlipayWallet, ALIPAY_WALLET, detectOSPlatform } from "./platform.js";
|
|
6
6
|
import { QueryWxSignatureStatus } from "./QueryWxSignatureStatus.js";
|
|
7
7
|
import { isGeoPositionEqual, alipayMyGetLocationSuccessResponse2GeolocationPosition, alipayMyGetLocationError2GeolocationPositionErrorCode, wxGetLocationSuccessResponse2GeolocationPosition } from "./transform.js";
|
|
8
|
+
import { toGeolocationGetCurrentPosition } from "./typeChecking.js";
|
|
8
9
|
const WX_INITIAL_GET_LOCATION_TIME_RATIO = 4;
|
|
9
10
|
const WX_SIGNATURE_TIMEOUT = 20 * 1e3;
|
|
10
11
|
const WX_GET_LOCATION_INTERVAL = 1 * 1e3;
|
|
@@ -200,7 +201,7 @@ const apGetLocation = ({ type, cacheTimeout, success, fail }) => {
|
|
|
200
201
|
const apType = type >= 2 ? 0 : type === 0 ? 2 : 1;
|
|
201
202
|
ap.getLocation({ type: apType, cacheTimeout }).then(success).catch(fail);
|
|
202
203
|
};
|
|
203
|
-
function androidWatchPosition(onSuccess, onError, option) {
|
|
204
|
+
function androidWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
204
205
|
let enable = true;
|
|
205
206
|
let prevGeoPosition = void 0;
|
|
206
207
|
let geoErrorMessage = void 0;
|
|
@@ -213,7 +214,7 @@ function androidWatchPosition(onSuccess, onError, option) {
|
|
|
213
214
|
}
|
|
214
215
|
const geoPosition = await new Promise((resolve) => {
|
|
215
216
|
let isHandled = false;
|
|
216
|
-
|
|
217
|
+
getLocationFn(
|
|
217
218
|
function onSuccess2(geoLocationPosition) {
|
|
218
219
|
if (isHandled)
|
|
219
220
|
return;
|
|
@@ -290,7 +291,12 @@ function compatibleWathPosition(onSuccess, onError, option) {
|
|
|
290
291
|
if (browserPlatform === BRWOSER_PLATFORM.ALIPAY || browserPlatform == BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM) {
|
|
291
292
|
return alipayWatchPosition(onSuccess, onError, option, (props) => my.getLocation(props));
|
|
292
293
|
}
|
|
293
|
-
return androidWatchPosition(onSuccess, onError, option)
|
|
294
|
+
return androidWatchPosition(onSuccess, onError, option, (...args) => {
|
|
295
|
+
return typeof HEYCAR_GEOLOCATION_GET_CURRENT_POSITION === "function" ? toGeolocationGetCurrentPosition(
|
|
296
|
+
HEYCAR_GEOLOCATION_GET_CURRENT_POSITION,
|
|
297
|
+
"HEYCAR_GEOLOCATION_GET_CURRENT_POSITION"
|
|
298
|
+
)(...args) : navigator.geolocation.getCurrentPosition(...args);
|
|
299
|
+
});
|
|
294
300
|
}
|
|
295
301
|
function compatibleGeoPositionTransform(position, transform) {
|
|
296
302
|
const platform = detectBrowserPlatform();
|
package/dist/v3/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.
|
|
3
|
+
const pkgVersion = "2.10.0";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
|
@@ -48,4 +48,5 @@ export declare const signal2promise: (signal?: AbortSignal) => Promise<any>;
|
|
|
48
48
|
export declare const googleEncodedPolyline2googleLatLng: (value: string) => google.maps.LatLng[];
|
|
49
49
|
export declare const gaodePolyline2amapLngLat: (value: string) => AMap.LngLat[];
|
|
50
50
|
export declare const amapTraffic2trafficStatus: (value?: AMap.TMC["status"]) => TrafficStatus;
|
|
51
|
+
export declare const error2beautifyString: (error: unknown) => string;
|
|
51
52
|
export {};
|
|
@@ -306,6 +306,15 @@ const amapTraffic2trafficStatus = (value) => {
|
|
|
306
306
|
return "HEAVY_TRAFFIC_JAM";
|
|
307
307
|
}
|
|
308
308
|
};
|
|
309
|
+
const error2beautifyString = (error) => {
|
|
310
|
+
if (typeof error === "string")
|
|
311
|
+
return error;
|
|
312
|
+
if (error instanceof GeolocationPositionError) {
|
|
313
|
+
const { code, message } = error;
|
|
314
|
+
return `GeolocationPositionError: code: ${code}, message: ${message}`;
|
|
315
|
+
}
|
|
316
|
+
return JSON.stringify(error, Object.getOwnPropertyNames(error), 2).replace(/\\n/g, "\n").replace(/\\"/g, '"');
|
|
317
|
+
};
|
|
309
318
|
export {
|
|
310
319
|
alipayMyGetLocationError2GeolocationPositionErrorCode,
|
|
311
320
|
alipayMyGetLocationSuccessResponse2GeolocationPosition,
|
|
@@ -316,6 +325,7 @@ export {
|
|
|
316
325
|
decodeAsterisk,
|
|
317
326
|
deltaZoom2animationDuration,
|
|
318
327
|
distanceVw2animationDuration,
|
|
328
|
+
error2beautifyString,
|
|
319
329
|
gaodePointsStringify,
|
|
320
330
|
gaodePolyline2amapLngLat,
|
|
321
331
|
geoPositionError2businessTimeout,
|
|
@@ -42,4 +42,13 @@ interface MaybeCoordinateTrackPoint {
|
|
|
42
42
|
}
|
|
43
43
|
export declare const toCoordinateTrackPoint: (value?: MaybeCoordinateTrackPoint) => CoordinateTrackPoint;
|
|
44
44
|
export declare function isProxyServiceError(error: unknown): error is ProxyServiceError;
|
|
45
|
+
export declare function toGeolocationPositionError(error: unknown, prefix?: string): GeolocationPositionError;
|
|
46
|
+
/**
|
|
47
|
+
* @warning: 目前只用到
|
|
48
|
+
* * GeolocationPosition.coords.latitude
|
|
49
|
+
* * GeolocationPosition.coords.longitude
|
|
50
|
+
* 如果将来用到其他属性,需要修补充
|
|
51
|
+
*/
|
|
52
|
+
export declare function assertGeolocationPosition(position: unknown): asserts position is GeolocationPosition;
|
|
53
|
+
export declare function toGeolocationGetCurrentPosition(fn: Geolocation["getCurrentPosition"], fnName?: string): Geolocation["getCurrentPosition"];
|
|
45
54
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { error2beautifyString } from "./transform.js";
|
|
1
2
|
const createTypeError = (typeName, value, detail) => {
|
|
2
3
|
if (detail)
|
|
3
4
|
return new Error(
|
|
@@ -109,7 +110,62 @@ const toCoordinateTrackPoint = (value) => {
|
|
|
109
110
|
function isProxyServiceError(error) {
|
|
110
111
|
return !!error && typeof error === "object" && "msg" in error && "code" in error;
|
|
111
112
|
}
|
|
113
|
+
function toGeolocationPositionError(error, prefix = "") {
|
|
114
|
+
if (error instanceof GeolocationPositionError)
|
|
115
|
+
return error;
|
|
116
|
+
if (typeof error === "object" && error !== null && "code" in error && (error.code === 1 || error.code === 2 || error.code === 3) && "message" in error && typeof error.message === "string") {
|
|
117
|
+
return error;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
code: 2,
|
|
121
|
+
message: prefix + `GeolocationPositionError 格式错误, origin error:
|
|
122
|
+
${error2beautifyString(error)}`
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function assertGeolocationPosition(position) {
|
|
126
|
+
if (position instanceof GeolocationPosition)
|
|
127
|
+
return;
|
|
128
|
+
if (typeof position !== "object" || position === null)
|
|
129
|
+
throw Error("GeolocationPosition 格式错误, 应当是一个非 null 的 object");
|
|
130
|
+
if (!("coords" in position) || typeof position.coords !== "object" || position.coords === null)
|
|
131
|
+
throw Error("GeolocationPosition 格式错误, coords 应当是非 null 的 object");
|
|
132
|
+
if (!("latitude" in position.coords) || typeof position.coords.latitude !== "number")
|
|
133
|
+
throw Error("GeolocationPosition 格式错误, latitude 应当是 number");
|
|
134
|
+
if (!("longitude" in position.coords) || typeof position.coords.longitude !== "number")
|
|
135
|
+
throw Error("GeolocationPosition 格式错误, longitude 应当是 number");
|
|
136
|
+
}
|
|
137
|
+
function toGeolocationGetCurrentPosition(fn, fnName = fn.name) {
|
|
138
|
+
const prefix = "ASSERT_GEOLOCATION_GET_CURRENT_POSITION_ERROR\n";
|
|
139
|
+
if (typeof fn !== "function")
|
|
140
|
+
throw Error(prefix + "Geolocation.getCurrentPosition 类型必须是一个 function");
|
|
141
|
+
return function assertedGetCurrentPosition(onSuccess, onError, options) {
|
|
142
|
+
const asseertedOnSuccess = (position) => {
|
|
143
|
+
try {
|
|
144
|
+
assertGeolocationPosition(position);
|
|
145
|
+
} catch (err) {
|
|
146
|
+
const { message } = err;
|
|
147
|
+
onError({
|
|
148
|
+
code: 2,
|
|
149
|
+
message: prefix + `${fnName} onSuccess 回调错误: ${message}`
|
|
150
|
+
});
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
onSuccess(position);
|
|
154
|
+
};
|
|
155
|
+
const asseertedOnError = (error) => onError(toGeolocationPositionError(error, prefix));
|
|
156
|
+
try {
|
|
157
|
+
fn(asseertedOnSuccess, asseertedOnError, options);
|
|
158
|
+
} catch (err) {
|
|
159
|
+
onError({
|
|
160
|
+
code: 2,
|
|
161
|
+
message: prefix + `${fnName} 运行异常:
|
|
162
|
+
${error2beautifyString(err)}`
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
112
167
|
export {
|
|
168
|
+
assertGeolocationPosition,
|
|
113
169
|
assertNoConflictTypeAndZone,
|
|
114
170
|
createTypeError,
|
|
115
171
|
isCoordinatePoint,
|
|
@@ -121,5 +177,7 @@ export {
|
|
|
121
177
|
toCoordinateRecommendZonePlacesType,
|
|
122
178
|
toCoordinateTrackPoint,
|
|
123
179
|
toCoordinateZoneType,
|
|
180
|
+
toGeolocationGetCurrentPosition,
|
|
181
|
+
toGeolocationPositionError,
|
|
124
182
|
toRecommendType
|
|
125
183
|
};
|