Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
20岁爱吃必胜客
uni-app
提交
5623740d
U
uni-app
项目概览
20岁爱吃必胜客
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5623740d
编写于
1月 09, 2020
作者:
d-u-a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: V3版本 vue <map> 部分 API 无效及部分属性不能动态更新的 Bug
上级
1e02476b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
31 deletion
+74
-31
src/core/service/api/context/create-map-context.js
src/core/service/api/context/create-map-context.js
+23
-17
src/platforms/app-plus/view/components/map/index.vue
src/platforms/app-plus/view/components/map/index.vue
+51
-14
未找到文件。
src/core/service/api/context/create-map-context.js
浏览文件 @
5623740d
import
{
import
{
invokeMethod
,
invokeMethod
,
getCurrentPageVm
getCurrentPageVm
}
from
'
../../platform
'
}
from
'
../../platform
'
import
{
callback
}
from
'
uni-shared
'
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
invokeMethod
(
'
operateMapPlayer
'
,
mapId
,
pageVm
,
type
,
data
)
invokeMethod
(
'
operateMapPlayer
'
,
mapId
,
pageVm
,
type
,
data
)
}
}
UniServiceJSBridge
.
subscribe
(
'
onMapMethodCallback
'
,
({
callbackId
,
data
})
=>
{
callback
.
invoke
(
callbackId
,
data
)
})
const
methods
=
[
'
getCenterLocation
'
,
'
translateMarker
'
,
'
getScale
'
,
'
getRegion
'
]
export
class
MapContext
{
export
class
MapContext
{
constructor
(
id
,
pageVm
)
{
constructor
(
id
,
pageVm
)
{
this
.
id
=
id
this
.
id
=
id
this
.
pageVm
=
pageVm
this
.
pageVm
=
pageVm
}
}
getCenterLocation
(
args
)
{
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
getCenterLocation
'
,
args
)
}
moveToLocation
()
{
moveToLocation
()
{
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
moveToLocation
'
)
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
moveToLocation
'
)
}
}
translateMarker
(
args
)
{
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
translateMarker
'
,
args
)
}
includePoints
(
args
)
{
includePoints
(
args
)
{
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
includePoints
'
,
args
)
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
includePoints
'
,
args
)
}
}
}
getRegion
(
args
)
{
methods
.
forEach
(
function
(
method
)
{
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
getRegion
'
,
args
)
MapContext
.
prototype
[
method
]
=
callback
.
warp
(
function
(
options
,
callbackId
)
{
}
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
method
,
{
options
,
getScale
(
args
)
{
callbackId
operateMapPlayer
(
this
.
id
,
this
.
pageVm
,
'
getScale
'
,
args
)
}
)
}
}
)
}
}
)
export
function
createMapContext
(
id
,
context
)
{
export
function
createMapContext
(
id
,
context
)
{
if
(
context
)
{
if
(
context
)
{
...
...
src/platforms/app-plus/view/components/map/index.vue
浏览文件 @
5623740d
...
@@ -146,7 +146,9 @@ export default {
...
@@ -146,7 +146,9 @@ export default {
const
list
=
this
.
controls
.
map
((
control
)
=>
{
const
list
=
this
.
controls
.
map
((
control
)
=>
{
let
position
=
{
position
:
'
absolute
'
};
let
position
=
{
position
:
'
absolute
'
};
[
'
top
'
,
'
left
'
,
'
width
'
,
'
height
'
].
forEach
(
key
=>
{
[
'
top
'
,
'
left
'
,
'
width
'
,
'
height
'
].
forEach
(
key
=>
{
position
[
key
]
=
control
.
position
[
key
]
+
'
px
'
if
(
control
.
position
[
key
])
{
position
[
key
]
=
control
.
position
[
key
]
+
'
px
'
}
})
})
return
{
return
{
id
:
control
.
id
,
id
:
control
.
id
,
...
@@ -160,6 +162,25 @@ export default {
...
@@ -160,6 +162,25 @@ export default {
watch
:
{
watch
:
{
hidden
(
val
)
{
hidden
(
val
)
{
this
.
map
&&
this
.
map
[
val
?
'
hide
'
:
'
show
'
]()
this
.
map
&&
this
.
map
[
val
?
'
hide
'
:
'
show
'
]()
},
latitude
(
val
)
{
this
.
map
&&
this
.
map
.
setStyles
({
center
:
new
plus
.
maps
.
Point
(
this
.
longitude
,
this
.
latitude
)
})
},
longitude
(
val
)
{
this
.
map
&&
this
.
map
.
setStyles
({
center
:
new
plus
.
maps
.
Point
(
this
.
longitude
,
this
.
latitude
)
})
},
markers
(
val
)
{
this
.
map
&&
this
.
_addMarkers
(
val
)
},
polyline
(
val
)
{
this
.
map
&&
this
.
_addMapLines
(
val
)
},
circles
(
val
)
{
this
.
map
&&
this
.
_addMapCircles
(
val
)
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -175,17 +196,6 @@ export default {
...
@@ -175,17 +196,6 @@ export default {
if
(
this
.
hidden
)
{
if
(
this
.
hidden
)
{
map
.
hide
()
map
.
hide
()
}
}
this
.
$watch
(
'
attrs
'
,
()
=>
{
if
(
this
.
map
)
{
this
.
map
.
setStyles
(
this
.
attrs
)
// TODO 临时处理更新 longitude, latitude 无效问题
this
.
map
.
setStyles
({
center
:
new
plus
.
maps
.
Point
(
this
.
longitude
,
this
.
latitude
)
})
}
},
{
deep
:
true
})
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
map
&&
this
.
map
.
setStyles
(
this
.
position
)
this
.
map
&&
this
.
map
.
setStyles
(
this
.
position
)
},
{
},
{
...
@@ -214,13 +224,40 @@ export default {
...
@@ -214,13 +224,40 @@ export default {
}
}
this
.
map
&&
this
[
type
](
data
)
this
.
map
&&
this
[
type
](
data
)
},
},
getRegion
()
{
moveToLocation
(
data
)
{
this
.
map
.
setCenter
(
new
plus
.
maps
.
Point
(
this
.
longitude
,
this
.
latitude
))
},
getCenterLocation
({
callbackId
})
{
const
center
=
this
.
map
.
getCenter
()
this
.
_publishHandler
(
callbackId
,
{
longitude
:
center
.
longitude
,
latitude
:
center
.
latitude
,
errMsg
:
'
getCenterLocation:ok
'
})
},
},
getScale
()
{
getRegion
({
callbackId
})
{
const
rect
=
this
.
map
.
getBounds
()
this
.
_publishHandler
(
callbackId
,
{
southwest
:
rect
.
southwest
,
northeast
:
rect
.
northeast
||
rect
.
northease
,
// 5plus API 名字写错了
errMsg
:
'
getRegion:ok
'
})
},
getScale
({
callbackId
})
{
this
.
_publishHandler
(
callbackId
,
{
scale
:
this
.
map
.
getZoom
(),
errMsg
:
'
getScale:ok
'
})
},
},
controlclick
(
e
)
{
controlclick
(
e
)
{
this
.
$trigger
(
'
controltap
'
,
{},
{
id
:
e
.
id
})
this
.
$trigger
(
'
controltap
'
,
{},
{
id
:
e
.
id
})
},
},
_publishHandler
(
callbackId
,
data
)
{
UniViewJSBridge
.
publishHandler
(
'
onMapMethodCallback
'
,
{
callbackId
,
data
},
this
.
$page
.
id
)
},
_addMarker
(
nativeMap
,
marker
)
{
_addMarker
(
nativeMap
,
marker
)
{
const
{
const
{
id
,
id
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录