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