Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yiicenne
uni-app
提交
27d3ed55
U
uni-app
项目概览
yiicenne
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
27d3ed55
编写于
4月 06, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(getLocation): ip定位取消坐标系转换 #4248
上级
d1edf51b
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
20 deletion
+29
-20
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
src/platforms/h5/helpers/location.js
src/platforms/h5/helpers/location.js
+4
-4
src/platforms/h5/service/api/location/get-location.js
src/platforms/h5/service/api/location/get-location.js
+22
-13
src/platforms/h5/service/api/location/location-change.js
src/platforms/h5/service/api/location/location-change.js
+2
-2
未找到文件。
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
27d3ed55
此差异已折叠。
点击以展开。
src/platforms/h5/helpers/location.js
浏览文件 @
27d3ed55
...
...
@@ -42,7 +42,7 @@ export function getMapInfo () {
export
const
IS_AMAP
=
getMapInfo
().
type
===
MapType
.
AMAP
export
function
translate
Geo
(
type
,
coords
,
skip
)
{
export
function
translate
CoordinateSystem
(
type
,
coords
,
skip
)
{
const
mapInfo
=
getMapInfo
()
const
wgs84Map
=
[
MapType
.
GOOGLE
]
if
(
...
...
@@ -77,10 +77,10 @@ export function translateGeo (type, coords, skip) {
speed
:
coords
.
speed
})
}
else
{
reject
(
new
Error
(
'
translate
geo
fail
'
))
reject
(
new
Error
(
'
translate
coordinate system
fail
'
))
}
},
()
=>
reject
(
new
Error
(
'
translate
geo
fail
'
))
()
=>
reject
(
new
Error
(
'
translate
coordinate system
fail
'
))
)
})
}
...
...
@@ -104,7 +104,7 @@ export function translateGeo (type, coords, skip) {
speed
:
coords
.
speed
})
}
else
{
reject
(
new
Error
(
'
translate
geo
fail
'
))
reject
(
new
Error
(
'
translate
coordinate system
fail
'
))
}
}
)
...
...
src/platforms/h5/service/api/location/get-location.js
浏览文件 @
27d3ed55
...
...
@@ -4,7 +4,7 @@ import {
import
{
MapType
,
getMapInfo
,
translate
Geo
translate
CoordinateSystem
}
from
'
../../../helpers/location
'
import
{
loadMaps
}
from
'
../../../view/components/map/maps
'
...
...
@@ -26,7 +26,7 @@ export function getLocation ({
new
Promise
((
resolve
,
reject
)
=>
{
if
(
navigator
.
geolocation
)
{
navigator
.
geolocation
.
getCurrentPosition
(
res
=>
resolve
(
res
.
coords
),
reject
,
{
navigator
.
geolocation
.
getCurrentPosition
(
res
=>
resolve
(
{
coords
:
res
.
coords
}
),
reject
,
{
enableHighAccuracy
:
isHighAccuracy
||
altitude
,
timeout
:
highAccuracyExpireTime
||
1000
*
100
})
...
...
@@ -42,9 +42,12 @@ export function getLocation ({
if
(
'
result
'
in
res
&&
res
.
result
.
location
)
{
const
location
=
res
.
result
.
location
resolve
({
latitude
:
location
.
lat
,
longitude
:
location
.
lng
},
true
)
coords
:
{
latitude
:
location
.
lat
,
longitude
:
location
.
lng
},
skip
:
true
})
}
else
{
reject
(
new
Error
(
res
.
message
||
JSON
.
stringify
(
res
)))
}
...
...
@@ -57,9 +60,12 @@ export function getLocation ({
const
data
=
res
.
data
if
(
'
location
'
in
data
)
{
resolve
({
latitude
:
data
.
location
.
lat
,
longitude
:
data
.
location
.
lng
,
accuracy
:
data
.
accuracy
coords
:
{
latitude
:
data
.
location
.
lat
,
longitude
:
data
.
location
.
lng
,
accuracy
:
data
.
accuracy
},
skip
:
true
})
}
else
{
reject
(
new
Error
((
data
.
error
&&
data
.
error
.
message
)
||
JSON
.
stringify
(
res
)))
...
...
@@ -80,9 +86,12 @@ export function getLocation ({
geolocation
.
getCurrentPosition
((
status
,
data
)
=>
{
if
(
status
===
'
complete
'
)
{
resolve
({
latitude
:
data
.
position
.
lat
,
longitude
:
data
.
position
.
lng
,
accuracy
:
data
.
accuracy
coords
:
{
latitude
:
data
.
position
.
lat
,
longitude
:
data
.
position
.
lng
,
accuracy
:
data
.
accuracy
},
skip
:
true
})
}
else
{
reject
(
new
Error
(
data
.
message
))
...
...
@@ -94,8 +103,8 @@ export function getLocation ({
reject
(
new
Error
(
'
network error
'
))
}
})
}).
then
((
coords
,
skip
)
=>
{
translate
Geo
(
type
,
coords
,
skip
)
}).
then
((
{
coords
,
skip
}
)
=>
{
translate
CoordinateSystem
(
type
,
coords
,
skip
)
.
then
(
coords
=>
{
invoke
(
callbackId
,
...
...
src/platforms/h5/service/api/location/location-change.js
浏览文件 @
27d3ed55
import
{
translate
Geo
}
from
'
../../../helpers/location
'
import
{
translate
CoordinateSystem
}
from
'
../../../helpers/location
'
const
{
invokeCallbackHandler
:
invoke
}
=
UniServiceJSBridge
let
successCallbackIds
=
[]
...
...
@@ -16,7 +16,7 @@ export function startLocationUpdate ({ type = 'gcj02' }, callbackId) {
watchId
=
watchId
||
navigator
.
geolocation
.
watchPosition
(
res
=>
{
started
=
true
translate
Geo
(
type
,
res
.
coords
)
translate
CoordinateSystem
(
type
,
res
.
coords
)
.
then
((
coords
)
=>
{
successCallbackIds
.
forEach
(
callbackId
=>
{
invoke
(
callbackId
,
coords
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录