提交 2aaef88f 编写于 作者: D DCloud_LXH

feat: getLocation add isHighAccuracy

上级 aa2ba317
...@@ -53,6 +53,7 @@ export function getLocation ({ ...@@ -53,6 +53,7 @@ export function getLocation ({
type = 'wgs84', type = 'wgs84',
geocode = false, geocode = false,
altitude = false, altitude = false,
isHighAccuracy = false,
highAccuracyExpireTime highAccuracyExpireTime
} = {}, callbackId) { } = {}, callbackId) {
const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation') const errorCallback = warpPlusErrorCallback(callbackId, 'getLocation')
...@@ -69,7 +70,7 @@ export function getLocation ({ ...@@ -69,7 +70,7 @@ export function getLocation ({
errorCallback(e) errorCallback(e)
}, { }, {
geocode: geocode, geocode: geocode,
enableHighAccuracy: altitude, enableHighAccuracy: isHighAccuracy || altitude,
timeout: highAccuracyExpireTime timeout: highAccuracyExpireTime
} }
) )
......
...@@ -14,6 +14,7 @@ import { ...@@ -14,6 +14,7 @@ import {
export function getLocation ({ export function getLocation ({
type, type,
altitude, altitude,
isHighAccuracy,
highAccuracyExpireTime highAccuracyExpireTime
}, callbackId) { }, callbackId) {
const { const {
...@@ -24,7 +25,7 @@ export function getLocation ({ ...@@ -24,7 +25,7 @@ export function getLocation ({
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
if (navigator.geolocation) { if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(res => resolve(res.coords), reject, { navigator.geolocation.getCurrentPosition(res => resolve(res.coords), reject, {
enableHighAccuracy: altitude, enableHighAccuracy: isHighAccuracy || altitude,
timeout: highAccuracyExpireTime || 1000 * 100 timeout: highAccuracyExpireTime || 1000 * 100
}) })
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册