@heycar/heycars-map 0.9.15 → 0.9.16
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/dist/index.cjs
CHANGED
|
@@ -12,7 +12,7 @@ if (typeof window !== "undefined" && typeof globalThis === "undefined") {
|
|
|
12
12
|
window.globalThis = window;
|
|
13
13
|
}
|
|
14
14
|
const name = "@heycar/heycars-map";
|
|
15
|
-
const version = "0.9.
|
|
15
|
+
const version = "0.9.16";
|
|
16
16
|
const type = "module";
|
|
17
17
|
const bin = {
|
|
18
18
|
checkVersion: "./bin/checkVersion.js"
|
|
@@ -2311,6 +2311,22 @@ var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
|
|
|
2311
2311
|
WEBGL_STATUS2["ENABLED"] = "ENABLED";
|
|
2312
2312
|
return WEBGL_STATUS2;
|
|
2313
2313
|
})(WEBGL_STATUS || {});
|
|
2314
|
+
var ALIPAY_WALLET = /* @__PURE__ */ ((ALIPAY_WALLET2) => {
|
|
2315
|
+
ALIPAY_WALLET2["TNGD"] = "TNGD";
|
|
2316
|
+
ALIPAY_WALLET2["TMN"] = "TMN";
|
|
2317
|
+
return ALIPAY_WALLET2;
|
|
2318
|
+
})(ALIPAY_WALLET || {});
|
|
2319
|
+
const detectAlipayWallet = () => {
|
|
2320
|
+
if (!navigator)
|
|
2321
|
+
return void 0;
|
|
2322
|
+
const useragent = navigator.userAgent.toLowerCase();
|
|
2323
|
+
if (!useragent.includes("alipay"))
|
|
2324
|
+
return void 0;
|
|
2325
|
+
if (useragent.includes("tngkit"))
|
|
2326
|
+
return "TNGD";
|
|
2327
|
+
if (useragent.includes("truemoney"))
|
|
2328
|
+
return "TMN";
|
|
2329
|
+
};
|
|
2314
2330
|
const detectBrowserPlatform = () => {
|
|
2315
2331
|
if (typeof navigator === "undefined")
|
|
2316
2332
|
return "NODE_JS";
|
|
@@ -4248,6 +4264,7 @@ function alipayWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
|
4248
4264
|
let prevGeoPosition = void 0;
|
|
4249
4265
|
const { timeout = ALIPAY_GEO_CACHE_TIMEOUT } = option;
|
|
4250
4266
|
const isGeoWorkingRef = Vue.ref(true);
|
|
4267
|
+
const lastSuccessfulResponseRef = Vue.ref();
|
|
4251
4268
|
const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
|
|
4252
4269
|
const startWatch = async () => {
|
|
4253
4270
|
do {
|
|
@@ -4256,14 +4273,22 @@ function alipayWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
|
4256
4273
|
continue;
|
|
4257
4274
|
}
|
|
4258
4275
|
const geoPosition = await new Promise((resolve) => {
|
|
4276
|
+
const handleSuccess = (res) => {
|
|
4277
|
+
lastSuccessfulResponseRef.value = res;
|
|
4278
|
+
isGeoWorkingRef.value = true;
|
|
4279
|
+
resolve(alipayMyGetLocationSuccessResponse2GeolocationPosition(res));
|
|
4280
|
+
};
|
|
4259
4281
|
getLocationFn({
|
|
4260
4282
|
type: 0,
|
|
4261
4283
|
cacheTimeout: timeout / 1e3,
|
|
4262
|
-
success
|
|
4263
|
-
isGeoWorkingRef.value = true;
|
|
4264
|
-
resolve(alipayMyGetLocationSuccessResponse2GeolocationPosition(res));
|
|
4265
|
-
},
|
|
4284
|
+
success: handleSuccess,
|
|
4266
4285
|
fail(res) {
|
|
4286
|
+
if (res.error === 13 && lastSuccessfulResponseRef.value) {
|
|
4287
|
+
console.warn(
|
|
4288
|
+
"MyWarning: my.getLocation failed with errcode 13 which has been bypassed"
|
|
4289
|
+
);
|
|
4290
|
+
return handleSuccess(lastSuccessfulResponseRef.value);
|
|
4291
|
+
}
|
|
4267
4292
|
const isGeoWorking = isGeoWorkingRef.value;
|
|
4268
4293
|
isGeoWorkingRef.value = false;
|
|
4269
4294
|
resolve(void 0);
|
|
@@ -4363,6 +4388,16 @@ function compatibleWathPosition(onSuccess, onError, option) {
|
|
|
4363
4388
|
const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
|
|
4364
4389
|
return () => navigator.geolocation.clearWatch(watchId);
|
|
4365
4390
|
}
|
|
4391
|
+
function compatibleGeoPositionTransform(position, transform) {
|
|
4392
|
+
const os = detectOSPlatform();
|
|
4393
|
+
const platform = detectBrowserPlatform();
|
|
4394
|
+
const wallet = detectAlipayWallet();
|
|
4395
|
+
if ((wallet === ALIPAY_WALLET.TNGD || wallet === ALIPAY_WALLET.TMN) && os === OS_PLATFORM.ANDROID)
|
|
4396
|
+
return transform(position);
|
|
4397
|
+
if (platform === BRWOSER_PLATFORM.ALIPAY || platform === BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM)
|
|
4398
|
+
return position;
|
|
4399
|
+
return transform(position);
|
|
4400
|
+
}
|
|
4366
4401
|
class SingleGeoWatch {
|
|
4367
4402
|
constructor(option) {
|
|
4368
4403
|
__publicField(this, "id", 0);
|
|
@@ -4441,9 +4476,6 @@ const useGeoLocation = (props) => {
|
|
|
4441
4476
|
var _a, _b;
|
|
4442
4477
|
const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
|
|
4443
4478
|
const { toGcj02 } = useMapGCJ02();
|
|
4444
|
-
const isAlipay = [BRWOSER_PLATFORM.ALIPAY, BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM].includes(
|
|
4445
|
-
detectBrowserPlatform()
|
|
4446
|
-
);
|
|
4447
4479
|
let isOnLoadTriggered = false;
|
|
4448
4480
|
const loading = Vue.ref(false);
|
|
4449
4481
|
const readyRef = Vue.ref(false);
|
|
@@ -4469,7 +4501,7 @@ const useGeoLocation = (props) => {
|
|
|
4469
4501
|
spaceLog("watchPosition", "success duration, position = ", duration, position);
|
|
4470
4502
|
const coordinate = position.coords;
|
|
4471
4503
|
const wgsPoint = [position.coords.longitude, position.coords.latitude];
|
|
4472
|
-
const point =
|
|
4504
|
+
const point = await compatibleGeoPositionTransform(wgsPoint, toGcj02);
|
|
4473
4505
|
coordinateRef.value = coordinate;
|
|
4474
4506
|
positionRef.value = point;
|
|
4475
4507
|
errorRef.value = void 0;
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ if (typeof window !== "undefined" && typeof globalThis === "undefined") {
|
|
|
10
10
|
window.globalThis = window;
|
|
11
11
|
}
|
|
12
12
|
const name = "@heycar/heycars-map";
|
|
13
|
-
const version = "0.9.
|
|
13
|
+
const version = "0.9.16";
|
|
14
14
|
const type = "module";
|
|
15
15
|
const bin = {
|
|
16
16
|
checkVersion: "./bin/checkVersion.js"
|
|
@@ -2309,6 +2309,22 @@ var WEBGL_STATUS = /* @__PURE__ */ ((WEBGL_STATUS2) => {
|
|
|
2309
2309
|
WEBGL_STATUS2["ENABLED"] = "ENABLED";
|
|
2310
2310
|
return WEBGL_STATUS2;
|
|
2311
2311
|
})(WEBGL_STATUS || {});
|
|
2312
|
+
var ALIPAY_WALLET = /* @__PURE__ */ ((ALIPAY_WALLET2) => {
|
|
2313
|
+
ALIPAY_WALLET2["TNGD"] = "TNGD";
|
|
2314
|
+
ALIPAY_WALLET2["TMN"] = "TMN";
|
|
2315
|
+
return ALIPAY_WALLET2;
|
|
2316
|
+
})(ALIPAY_WALLET || {});
|
|
2317
|
+
const detectAlipayWallet = () => {
|
|
2318
|
+
if (!navigator)
|
|
2319
|
+
return void 0;
|
|
2320
|
+
const useragent = navigator.userAgent.toLowerCase();
|
|
2321
|
+
if (!useragent.includes("alipay"))
|
|
2322
|
+
return void 0;
|
|
2323
|
+
if (useragent.includes("tngkit"))
|
|
2324
|
+
return "TNGD";
|
|
2325
|
+
if (useragent.includes("truemoney"))
|
|
2326
|
+
return "TMN";
|
|
2327
|
+
};
|
|
2312
2328
|
const detectBrowserPlatform = () => {
|
|
2313
2329
|
if (typeof navigator === "undefined")
|
|
2314
2330
|
return "NODE_JS";
|
|
@@ -4246,6 +4262,7 @@ function alipayWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
|
4246
4262
|
let prevGeoPosition = void 0;
|
|
4247
4263
|
const { timeout = ALIPAY_GEO_CACHE_TIMEOUT } = option;
|
|
4248
4264
|
const isGeoWorkingRef = ref(true);
|
|
4265
|
+
const lastSuccessfulResponseRef = ref();
|
|
4249
4266
|
const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
|
|
4250
4267
|
const startWatch = async () => {
|
|
4251
4268
|
do {
|
|
@@ -4254,14 +4271,22 @@ function alipayWatchPosition(onSuccess, onError, option, getLocationFn) {
|
|
|
4254
4271
|
continue;
|
|
4255
4272
|
}
|
|
4256
4273
|
const geoPosition = await new Promise((resolve) => {
|
|
4274
|
+
const handleSuccess = (res) => {
|
|
4275
|
+
lastSuccessfulResponseRef.value = res;
|
|
4276
|
+
isGeoWorkingRef.value = true;
|
|
4277
|
+
resolve(alipayMyGetLocationSuccessResponse2GeolocationPosition(res));
|
|
4278
|
+
};
|
|
4257
4279
|
getLocationFn({
|
|
4258
4280
|
type: 0,
|
|
4259
4281
|
cacheTimeout: timeout / 1e3,
|
|
4260
|
-
success
|
|
4261
|
-
isGeoWorkingRef.value = true;
|
|
4262
|
-
resolve(alipayMyGetLocationSuccessResponse2GeolocationPosition(res));
|
|
4263
|
-
},
|
|
4282
|
+
success: handleSuccess,
|
|
4264
4283
|
fail(res) {
|
|
4284
|
+
if (res.error === 13 && lastSuccessfulResponseRef.value) {
|
|
4285
|
+
console.warn(
|
|
4286
|
+
"MyWarning: my.getLocation failed with errcode 13 which has been bypassed"
|
|
4287
|
+
);
|
|
4288
|
+
return handleSuccess(lastSuccessfulResponseRef.value);
|
|
4289
|
+
}
|
|
4265
4290
|
const isGeoWorking = isGeoWorkingRef.value;
|
|
4266
4291
|
isGeoWorkingRef.value = false;
|
|
4267
4292
|
resolve(void 0);
|
|
@@ -4361,6 +4386,16 @@ function compatibleWathPosition(onSuccess, onError, option) {
|
|
|
4361
4386
|
const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
|
|
4362
4387
|
return () => navigator.geolocation.clearWatch(watchId);
|
|
4363
4388
|
}
|
|
4389
|
+
function compatibleGeoPositionTransform(position, transform) {
|
|
4390
|
+
const os = detectOSPlatform();
|
|
4391
|
+
const platform = detectBrowserPlatform();
|
|
4392
|
+
const wallet = detectAlipayWallet();
|
|
4393
|
+
if ((wallet === ALIPAY_WALLET.TNGD || wallet === ALIPAY_WALLET.TMN) && os === OS_PLATFORM.ANDROID)
|
|
4394
|
+
return transform(position);
|
|
4395
|
+
if (platform === BRWOSER_PLATFORM.ALIPAY || platform === BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM)
|
|
4396
|
+
return position;
|
|
4397
|
+
return transform(position);
|
|
4398
|
+
}
|
|
4364
4399
|
class SingleGeoWatch {
|
|
4365
4400
|
constructor(option) {
|
|
4366
4401
|
__publicField(this, "id", 0);
|
|
@@ -4439,9 +4474,6 @@ const useGeoLocation = (props) => {
|
|
|
4439
4474
|
var _a, _b;
|
|
4440
4475
|
const { onChange, onLoad, onLoadDefault, onError, geoDefaultPosition } = props != null ? props : {};
|
|
4441
4476
|
const { toGcj02 } = useMapGCJ02();
|
|
4442
|
-
const isAlipay = [BRWOSER_PLATFORM.ALIPAY, BRWOSER_PLATFORM.ALIPAY_MINIPROGRAM].includes(
|
|
4443
|
-
detectBrowserPlatform()
|
|
4444
|
-
);
|
|
4445
4477
|
let isOnLoadTriggered = false;
|
|
4446
4478
|
const loading = ref(false);
|
|
4447
4479
|
const readyRef = ref(false);
|
|
@@ -4467,7 +4499,7 @@ const useGeoLocation = (props) => {
|
|
|
4467
4499
|
spaceLog("watchPosition", "success duration, position = ", duration, position);
|
|
4468
4500
|
const coordinate = position.coords;
|
|
4469
4501
|
const wgsPoint = [position.coords.longitude, position.coords.latitude];
|
|
4470
|
-
const point =
|
|
4502
|
+
const point = await compatibleGeoPositionTransform(wgsPoint, toGcj02);
|
|
4471
4503
|
coordinateRef.value = coordinate;
|
|
4472
4504
|
positionRef.value = point;
|
|
4473
4505
|
errorRef.value = void 0;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import type { Point } from "../types/interface";
|
|
1
2
|
export type ClearWathPosition = () => void;
|
|
2
3
|
export declare function compatibleWathPosition(onSuccess: PositionCallback, onError: PositionErrorCallback, option: PositionOptions): ClearWathPosition;
|
|
4
|
+
type AsyncPointTransformer = (p: Point) => Promise<Point>;
|
|
5
|
+
/**
|
|
6
|
+
* 统一客户端加偏转换
|
|
7
|
+
* @param position 经纬度
|
|
8
|
+
* @param transform 加偏转换 wgs84 -> gcj02
|
|
9
|
+
*/
|
|
10
|
+
export declare function compatibleGeoPositionTransform(position: Point, transform: AsyncPointTransformer): Point | Promise<Point>;
|
|
11
|
+
export {};
|
|
@@ -16,6 +16,11 @@ export declare enum WEBGL_STATUS {
|
|
|
16
16
|
DISABLED = "DISABLED",
|
|
17
17
|
ENABLED = "ENABLED"
|
|
18
18
|
}
|
|
19
|
+
export declare enum ALIPAY_WALLET {
|
|
20
|
+
TNGD = "TNGD",
|
|
21
|
+
TMN = "TMN"
|
|
22
|
+
}
|
|
23
|
+
export declare const detectAlipayWallet: () => ALIPAY_WALLET | undefined;
|
|
19
24
|
export declare const detectBrowserPlatform: () => BRWOSER_PLATFORM;
|
|
20
25
|
export declare const detectOSPlatform: () => OS_PLATFORM;
|
|
21
26
|
/**
|