Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小浣熊撸代码
uni-app
提交
de8bd5b5
U
uni-app
项目概览
小浣熊撸代码
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
de8bd5b5
编写于
7月 30, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(App): Map
上级
cfcd3324
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
36 addition
and
23 deletion
+36
-23
packages/uni-api/src/service/context/createMapContext.ts
packages/uni-api/src/service/context/createMapContext.ts
+5
-3
packages/uni-app-plus/src/view/components/map/index.tsx
packages/uni-app-plus/src/view/components/map/index.tsx
+31
-20
未找到文件。
packages/uni-api/src/service/context/createMapContext.ts
浏览文件 @
de8bd5b5
...
...
@@ -24,7 +24,7 @@ const operateMapWrap = (
id
:
string
,
pageId
:
number
,
type
:
string
,
options
?:
Data
options
?:
any
)
=>
{
operateMap
(
id
,
pageId
,
type
,
options
,
(
res
)
=>
{
options
&&
operateMapCallback
(
options
,
res
)
...
...
@@ -41,8 +41,9 @@ export class MapContext implements UniApp.MapContext {
getCenterLocation
(
options
:
any
)
{
operateMapWrap
(
this
.
id
,
this
.
pageId
,
'
getCenterLocation
'
,
options
)
}
moveToLocation
()
{
operateMapWrap
(
this
.
id
,
this
.
pageId
,
'
moveToLocation
'
)
// @ts-expect-error
moveToLocation
(
options
:
any
)
{
operateMapWrap
(
this
.
id
,
this
.
pageId
,
'
moveToLocation
'
,
options
)
}
getScale
(
options
:
any
)
{
operateMapWrap
(
this
.
id
,
this
.
pageId
,
'
getScale
'
,
options
)
...
...
@@ -73,6 +74,7 @@ export class MapContext implements UniApp.MapContext {
openMapApp
()
{}
}
// @ts-expect-error
export
const
createMapContext
=
<
API_TYPE_CREATE_MAP_CONTEXT
>
defineSyncApi
(
API_CREATE_MAP_CONTEXT
,
(
id
,
context
)
=>
{
...
...
packages/uni-app-plus/src/view/components/map/index.tsx
浏览文件 @
de8bd5b5
...
...
@@ -18,6 +18,7 @@ import {
import
{
useNativeAttrs
,
useNative
}
from
'
../../../helpers/useNative
'
import
{
getCurrentPageId
}
from
'
@dcloudio/uni-core
'
import
{
getRealPath
}
from
'
../../../platform/getRealPath
'
import
CoverImage
from
'
../cover-image
'
interface
Coordinate
{
latitude
:
number
...
...
@@ -83,7 +84,6 @@ type Control = {
}
interface
Map
extends
PlusMapsMap
{
__markers__
:
Markers
__markers_map__
:
Record
<
string
,
PlusMapsMarker
>
__lines__
:
Lines
__circles__
:
Circles
}
...
...
@@ -152,11 +152,24 @@ export default /*#__PURE__*/ defineBuiltInComponent({
map
=
extend
(
plus
.
maps
.
create
(
getCurrentPageId
()
+
'
-map-
'
+
(
props
.
id
||
Date
.
now
()),
Object
.
assign
({},
attrs
.
value
,
position
)
Object
.
assign
(
{},
attrs
.
value
,
position
,
(()
=>
{
if
(
props
.
latitude
&&
props
.
longitude
)
{
return
{
center
:
new
plus
.
maps
.
Point
!
(
Number
(
props
.
longitude
),
Number
(
props
.
latitude
)
),
}
}
})()
)
),
{
__markers__
:
[],
__markers_map__
:
{},
__lines__
:
[],
__circles__
:
[],
}
...
...
@@ -187,12 +200,9 @@ export default /*#__PURE__*/ defineBuiltInComponent({
(
position
)
=>
map
&&
map
.
setStyles
(
position
),
{
deep
:
true
}
)
watch
(
()
=>
hidden
.
value
,
(
val
)
=>
{
watch
(
hidden
,
(
val
)
=>
{
map
&&
map
[
val
?
'
hide
'
:
'
show
'
]()
}
)
})
watch
(
()
=>
props
.
scale
,
(
val
)
=>
{
...
...
@@ -212,19 +222,22 @@ export default /*#__PURE__*/ defineBuiltInComponent({
()
=>
props
.
markers
,
(
val
)
=>
{
_addMarkers
(
val
as
Markers
,
true
)
}
},
{
deep
:
true
}
)
watch
(
()
=>
props
.
polyline
,
(
val
)
=>
{
_addMapLines
(
val
as
Lines
)
}
},
{
deep
:
true
}
)
watch
(
()
=>
props
.
circles
,
(
val
)
=>
{
_addMapCircles
(
val
as
Circles
)
}
},
{
deep
:
true
}
)
})
...
...
@@ -240,6 +253,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
id
:
control
.
id
,
iconPath
:
getRealPath
(
control
.
iconPath
),
position
:
position
,
clickable
:
control
.
clickable
,
}
})
)
...
...
@@ -256,12 +270,14 @@ export default /*#__PURE__*/ defineBuiltInComponent({
<
uni
-
map
ref
=
{
rootRef
}
id
=
{
props
.
id
}
>
<
div
ref
=
{
containerRef
}
class
=
"uni-map-container"
/>
{
mapControls
.
value
.
map
((
control
,
index
)
=>
(
<
v
-
uni
-
cover
-
i
mage
<
CoverI
mage
key
=
{
index
}
src
=
{
control
.
iconPath
}
style
=
{
control
.
position
}
auto
-
size
// @ts-expect-error
onClick
=
{
()
=>
control
.
clickable
&&
trigger
(
'
controltap
'
,
{}
as
Event
,
{
controlId
:
control
.
id
})
}
/>
...
...
@@ -278,10 +294,7 @@ function useMapMethods(props: Props, trigger: CustomEventTrigger) {
let
map
:
Map
|
null
function
moveToLocation
(
resolve
:
Callback
,
{
longitude
,
latitude
,
}:
{
longitude
?:
Props
[
'
longitude
'
];
latitude
?:
Props
[
'
latitude
'
]
}
=
{}
{
longitude
,
latitude
}:
Partial
<
Coordinate
>
=
{}
)
{
if
(
!
map
)
return
map
.
setCenter
(
...
...
@@ -310,7 +323,7 @@ function useMapMethods(props: Props, trigger: CustomEventTrigger) {
const
rect
=
map
.
getBounds
()
resolve
({
southwest
:
rect
.
getSouthWest
(),
northeast
:
rect
.
getNorthEast
(),
// 5plus API 名字写错了
northeast
:
rect
.
getNorthEast
(),
errMsg
:
'
getRegion:ok
'
,
})
}
...
...
@@ -373,7 +386,6 @@ function useMapMethods(props: Props, trigger: CustomEventTrigger) {
// 此处5+文档中PlusMapsMarker对象只有方法,没有属性
// @ts-expect-error
map
.
__markers__
.
push
(
nativeMarker
)
map
&&
(
map
.
__markers_map__
[
id
+
''
]
=
nativeMarker
)
})
}
function
_clearMarkers
()
{
...
...
@@ -383,7 +395,6 @@ function useMapMethods(props: Props, trigger: CustomEventTrigger) {
map
?.
removeOverlay
(
marker
as
unknown
as
PlusMapsOverlay
)
})
map
.
__markers__
=
[]
map
.
__markers_map__
=
{}
}
function
_addMarkers
(
markers
:
Markers
,
clear
?:
boolean
)
{
if
(
clear
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录