diff --git a/package.json b/package.json index 406b71c7b7f30f03699d805323e4d841a6ac6a2e..8375f4fc21e3251ae0c810aee500b7c50b56a3f6 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 cf9e2b95e9db09523514b7ba08c05860c73d2f85..91480df1795fc4af41aa8ad6dee519ad191a144d 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 513cb9165b62ac3dfc9062ec7124242049dc191a..3715e24b0937ea994eebda9dd7566527aa1b0048 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, } )