From 789d97189250aae1e1744667f24bf353df1ad7d3 Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Tue, 14 Dec 2021 17:32:26 +0800 Subject: [PATCH] feat: getLocation add isHighAccuracy --- package.json | 2 +- .../uni-app-plus/src/service/api/location/getLocation.ts | 3 ++- packages/uni-h5/src/service/api/location/getLocation.ts | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 406b71c7b..8375f4fc2 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "node": ">=10.0.0" }, "devDependencies": { - "@dcloudio/types": "^2.5.13", + "@dcloudio/types": "^2.5.14", "@dcloudio/uni-api": "3.0.0-alpha-3030120211213002", "@jest/types": "^27.0.2", "@microsoft/api-extractor": "^7.19.2", diff --git a/packages/uni-app-plus/src/service/api/location/getLocation.ts b/packages/uni-app-plus/src/service/api/location/getLocation.ts index cf9e2b95e..91480df17 100644 --- a/packages/uni-app-plus/src/service/api/location/getLocation.ts +++ b/packages/uni-app-plus/src/service/api/location/getLocation.ts @@ -47,6 +47,7 @@ export const getLocation = defineAsyncApi( geocode = false, altitude = false, highAccuracyExpireTime, + isHighAccuracy = false, }, { resolve, reject } ) => { @@ -65,7 +66,7 @@ export const getLocation = defineAsyncApi( }, { geocode: geocode, - enableHighAccuracy: altitude, + enableHighAccuracy: isHighAccuracy || altitude, timeout: highAccuracyExpireTime, } ) diff --git a/packages/uni-h5/src/service/api/location/getLocation.ts b/packages/uni-h5/src/service/api/location/getLocation.ts index 513cb9165..3715e24b0 100644 --- a/packages/uni-h5/src/service/api/location/getLocation.ts +++ b/packages/uni-h5/src/service/api/location/getLocation.ts @@ -14,7 +14,10 @@ type GeoRes = (coords: GeolocationCoordinates, skip?: boolean) => void export const getLocation = defineAsyncApi( API_GET_LOCATION, - ({ type, altitude, highAccuracyExpireTime }, { resolve, reject }) => { + ( + { type, altitude, highAccuracyExpireTime, isHighAccuracy }, + { resolve, reject } + ) => { const mapInfo = getMapInfo() new Promise((resolve: GeoRes, reject) => { @@ -23,7 +26,7 @@ export const getLocation = defineAsyncApi( (res) => resolve(res.coords), reject, { - enableHighAccuracy: altitude, + enableHighAccuracy: isHighAccuracy || altitude, timeout: highAccuracyExpireTime || 1000 * 100, } ) -- GitLab