Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
a34d87f8
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
805
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a34d87f8
编写于
10月 12, 2023
作者:
染小白
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(map): add event
上级
493aa077
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
151 addition
and
27 deletion
+151
-27
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+49
-9
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+65
-11
packages/uni-h5/src/view/components/map/index.tsx
packages/uni-h5/src/view/components/map/index.tsx
+33
-2
packages/uni-h5/src/view/components/map/map-polygon/index.tsx
...ages/uni-h5/src/view/components/map/map-polygon/index.tsx
+0
-1
pnpm-lock.yaml
pnpm-lock.yaml
+4
-4
未找到文件。
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
a34d87f8
...
@@ -9176,7 +9176,14 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
...
@@ -9176,7 +9176,14 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
function
addPolyline
(
option
)
{
function
addPolyline
(
option
)
{
const
path
=
[];
const
path
=
[];
option
.
points
.
forEach
((
point
)
=>
{
option
.
points
.
forEach
((
point
)
=>
{
const
pointPosition
=
getIsAMap
()
?
[
point
.
longitude
,
point
.
latitude
]
:
new
maps
.
LatLng
(
point
.
latitude
,
point
.
longitude
);
let
pointPosition
;
if
(
getIsAMap
())
{
pointPosition
=
[
point
.
longitude
,
point
.
latitude
];
}
else
if
(
getIsBMap
())
{
pointPosition
=
new
maps
.
Point
(
point
.
longitude
,
point
.
latitude
);
}
else
{
pointPosition
=
new
maps
.
LatLng
(
point
.
latitude
,
point
.
longitude
);
}
path
.
push
(
pointPosition
);
path
.
push
(
pointPosition
);
});
});
const
strokeWeight
=
Number
(
option
.
width
)
||
1
;
const
strokeWeight
=
Number
(
option
.
width
)
||
1
;
...
@@ -9221,7 +9228,12 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
...
@@ -9221,7 +9228,12 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
if
(
borderWidth
)
{
if
(
borderWidth
)
{
polylineBorder
=
new
maps
.
Polyline
(
polylineBorderOptions
);
polylineBorder
=
new
maps
.
Polyline
(
polylineBorderOptions
);
}
}
polyline
=
new
maps
.
Polyline
(
polylineOptions
);
if
(
getIsBMap
())
{
polyline
=
new
maps
.
Polyline
(
polylineOptions
.
path
,
polylineOptions
);
map
.
addOverlay
(
polyline
);
}
else
{
polyline
=
new
maps
.
Polyline
(
polylineOptions
);
}
}
}
addPolyline
(
props2
);
addPolyline
(
props2
);
vue
.
watch
(
props2
,
updatePolyline
);
vue
.
watch
(
props2
,
updatePolyline
);
...
@@ -9278,7 +9290,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
...
@@ -9278,7 +9290,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
addCircle
(
option
);
addCircle
(
option
);
}
}
function
addCircle
(
option
)
{
function
addCircle
(
option
)
{
const
center
=
getIsAMap
()
?
[
option
.
longitude
,
option
.
latitude
]
:
new
maps
.
LatLng
(
option
.
latitude
,
option
.
longitude
);
const
center
=
getIsAMap
()
||
getIsBMap
()
?
[
option
.
longitude
,
option
.
latitude
]
:
new
maps
.
LatLng
(
option
.
latitude
,
option
.
longitude
);
const
circleOptions
=
{
const
circleOptions
=
{
map
,
map
,
center
,
center
,
...
@@ -9287,7 +9299,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
...
@@ -9287,7 +9299,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
strokeWeight
:
Number
(
option
.
strokeWidth
)
||
1
,
strokeWeight
:
Number
(
option
.
strokeWidth
)
||
1
,
strokeDashStyle
:
"
solid
"
strokeDashStyle
:
"
solid
"
};
};
if
(
getIsAMap
())
{
if
(
getIsAMap
()
||
getIsBMap
()
)
{
circleOptions
.
strokeColor
=
option
.
color
;
circleOptions
.
strokeColor
=
option
.
color
;
circleOptions
.
fillColor
=
option
.
fillColor
||
"
#000
"
;
circleOptions
.
fillColor
=
option
.
fillColor
||
"
#000
"
;
circleOptions
.
fillOpacity
=
1
;
circleOptions
.
fillOpacity
=
1
;
...
@@ -9314,9 +9326,20 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
...
@@ -9314,9 +9326,20 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
circleOptions
.
strokeOpacity
=
sa
;
circleOptions
.
strokeOpacity
=
sa
;
}
}
}
}
circle
=
new
maps
.
Circle
(
circleOptions
);
if
(
getIsBMap
())
{
if
(
getIsAMap
())
{
let
pt
=
new
maps
.
Point
(
map
.
add
(
circle
);
// @ts-ignore
circleOptions
.
center
[
0
],
// @ts-ignore
circleOptions
.
center
[
1
]
);
circle
=
new
maps
.
Circle
(
pt
,
circleOptions
.
radius
,
circleOptions
);
map
.
addOverlay
(
circle
);
}
else
{
circle
=
new
maps
.
Circle
(
circleOptions
);
if
(
getIsAMap
())
{
map
.
add
(
circle
);
}
}
}
}
}
addCircle
(
props2
);
addCircle
(
props2
);
...
@@ -9458,7 +9481,13 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
...
@@ -9458,7 +9481,13 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
latitude
,
latitude
,
longitude
longitude
}
=
item
;
}
=
item
;
return
getIsAMap
()
?
[
longitude
,
latitude
]
:
new
maps
.
LatLng
(
latitude
,
longitude
);
if
(
getIsAMap
())
{
return
[
longitude
,
latitude
];
}
else
if
(
getIsBMap
())
{
return
new
maps
.
Point
(
longitude
,
latitude
);
}
else
{
return
new
maps
.
LatLng
(
latitude
,
longitude
);
}
});
});
const
{
const
{
r
:
fcR
,
r
:
fcR
,
...
@@ -9510,7 +9539,12 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
...
@@ -9510,7 +9539,12 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
polygonIns
.
setOptions
(
polygonOptions
);
polygonIns
.
setOptions
(
polygonOptions
);
return
;
return
;
}
}
polygonIns
=
new
maps
.
Polygon
(
polygonOptions
);
if
(
getIsBMap
())
{
polygonIns
=
new
maps
.
Polygon
(
polygonOptions
.
path
,
polygonOptions
);
map
.
addOverlay
(
polygonIns
);
}
else
{
polygonIns
=
new
maps
.
Polygon
(
polygonOptions
);
}
}
}
drawPolygon
();
drawPolygon
();
vue
.
watch
(
props2
,
drawPolygon
);
vue
.
watch
(
props2
,
drawPolygon
);
...
@@ -9616,6 +9650,9 @@ function getLat(latLng) {
...
@@ -9616,6 +9650,9 @@ function getLat(latLng) {
if
(
"
getLat
"
in
latLng
)
{
if
(
"
getLat
"
in
latLng
)
{
return
latLng
.
getLat
();
return
latLng
.
getLat
();
}
else
{
}
else
{
if
(
getIsBMap
())
{
return
latLng
.
lat
;
}
return
latLng
.
lat
();
return
latLng
.
lat
();
}
}
}
}
...
@@ -9623,6 +9660,9 @@ function getLng(latLng) {
...
@@ -9623,6 +9660,9 @@ function getLng(latLng) {
if
(
"
getLng
"
in
latLng
)
{
if
(
"
getLng
"
in
latLng
)
{
return
latLng
.
getLng
();
return
latLng
.
getLng
();
}
else
{
}
else
{
if
(
getIsBMap
())
{
return
latLng
.
lng
;
}
return
latLng
.
lng
();
return
latLng
.
lng
();
}
}
}
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
a34d87f8
...
@@ -17625,7 +17625,14 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
...
@@ -17625,7 +17625,14 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
function addPolyline(option) {
function addPolyline(option) {
const path = [];
const path = [];
option.points.forEach((point) => {
option.points.forEach((point) => {
const pointPosition = getIsAMap() ? [point.longitude, point.latitude] : new maps2.LatLng(point.latitude, point.longitude);
let pointPosition;
if (getIsAMap()) {
pointPosition = [point.longitude, point.latitude];
} else if (getIsBMap()) {
pointPosition = new maps2.Point(point.longitude, point.latitude);
} else {
pointPosition = new maps2.LatLng(point.latitude, point.longitude);
}
path.push(pointPosition);
path.push(pointPosition);
});
});
const strokeWeight = Number(option.width) || 1;
const strokeWeight = Number(option.width) || 1;
...
@@ -17670,7 +17677,12 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
...
@@ -17670,7 +17677,12 @@ const MapPolyline = /* @__PURE__ */ defineSystemComponent({
if (borderWidth) {
if (borderWidth) {
polylineBorder = new maps2.Polyline(polylineBorderOptions);
polylineBorder = new maps2.Polyline(polylineBorderOptions);
}
}
polyline = new maps2.Polyline(polylineOptions);
if (getIsBMap()) {
polyline = new maps2.Polyline(polylineOptions.path, polylineOptions);
map.addOverlay(polyline);
} else {
polyline = new maps2.Polyline(polylineOptions);
}
}
}
addPolyline(props2);
addPolyline(props2);
watch(props2, updatePolyline);
watch(props2, updatePolyline);
...
@@ -17728,7 +17740,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
...
@@ -17728,7 +17740,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
addCircle(option);
addCircle(option);
}
}
function addCircle(option) {
function addCircle(option) {
const center = getIsAMap() ? [option.longitude, option.latitude] : new maps2.LatLng(option.latitude, option.longitude);
const center = getIsAMap()
|| getIsBMap()
? [option.longitude, option.latitude] : new maps2.LatLng(option.latitude, option.longitude);
const circleOptions = {
const circleOptions = {
map,
map,
center,
center,
...
@@ -17737,7 +17749,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
...
@@ -17737,7 +17749,7 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
strokeWeight: Number(option.strokeWidth) || 1,
strokeWeight: Number(option.strokeWidth) || 1,
strokeDashStyle: "solid"
strokeDashStyle: "solid"
};
};
if (getIsAMap()) {
if (getIsAMap()
|| getIsBMap()
) {
circleOptions.strokeColor = option.color;
circleOptions.strokeColor = option.color;
circleOptions.fillColor = option.fillColor || "#000";
circleOptions.fillColor = option.fillColor || "#000";
circleOptions.fillOpacity = 1;
circleOptions.fillOpacity = 1;
...
@@ -17764,9 +17776,20 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
...
@@ -17764,9 +17776,20 @@ const MapCircle = /* @__PURE__ */ defineSystemComponent({
circleOptions.strokeOpacity = sa;
circleOptions.strokeOpacity = sa;
}
}
}
}
circle = new maps2.Circle(circleOptions);
if (getIsBMap()) {
if (getIsAMap()) {
let pt = new maps2.Point(
map.add(circle);
// @ts-ignore
circleOptions.center[0],
// @ts-ignore
circleOptions.center[1]
);
circle = new maps2.Circle(pt, circleOptions.radius, circleOptions);
map.addOverlay(circle);
} else {
circle = new maps2.Circle(circleOptions);
if (getIsAMap()) {
map.add(circle);
}
}
}
}
}
addCircle(props2);
addCircle(props2);
...
@@ -23149,7 +23172,13 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
...
@@ -23149,7 +23172,13 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
latitude,
latitude,
longitude
longitude
} = item;
} = item;
return getIsAMap() ? [longitude, latitude] : new maps2.LatLng(latitude, longitude);
if (getIsAMap()) {
return [longitude, latitude];
} else if (getIsBMap()) {
return new maps2.Point(longitude, latitude);
} else {
return new maps2.LatLng(latitude, longitude);
}
});
});
const {
const {
r: fcR,
r: fcR,
...
@@ -23201,7 +23230,12 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
...
@@ -23201,7 +23230,12 @@ const MapPolygon = /* @__PURE__ */ defineSystemComponent({
polygonIns.setOptions(polygonOptions);
polygonIns.setOptions(polygonOptions);
return;
return;
}
}
polygonIns = new maps2.Polygon(polygonOptions);
if (getIsBMap()) {
polygonIns = new maps2.Polygon(polygonOptions.path, polygonOptions);
map.addOverlay(polygonIns);
} else {
polygonIns = new maps2.Polygon(polygonOptions);
}
}
}
drawPolygon();
drawPolygon();
watch(props2, drawPolygon);
watch(props2, drawPolygon);
...
@@ -23310,6 +23344,9 @@ function getLat(latLng) {
...
@@ -23310,6 +23344,9 @@ function getLat(latLng) {
if ("getLat" in latLng) {
if ("getLat" in latLng) {
return latLng.getLat();
return latLng.getLat();
} else {
} else {
if (getIsBMap()) {
return latLng.lat;
}
return latLng.lat();
return latLng.lat();
}
}
}
}
...
@@ -23317,6 +23354,9 @@ function getLng(latLng) {
...
@@ -23317,6 +23354,9 @@ function getLng(latLng) {
if ("getLng" in latLng) {
if ("getLng" in latLng) {
return latLng.getLng();
return latLng.getLng();
} else {
} else {
if (getIsBMap()) {
return latLng.lng;
}
return latLng.lng();
return latLng.lng();
}
}
}
}
...
@@ -23425,7 +23465,6 @@ function useMap(props2, rootRef, emit2) {
...
@@ -23425,7 +23465,6 @@ function useMap(props2, rootRef, emit2) {
const mapEl = mapRef.value;
const mapEl = mapRef.value;
const center = getMapPosition(maps2, state2.latitude, state2.longitude);
const center = getMapPosition(maps2, state2.latitude, state2.longitude);
const event = maps2.event || maps2.Event;
const event = maps2.event || maps2.Event;
console.log("event:", event);
const map2 = new maps2.Map(mapEl, {
const map2 = new maps2.Map(mapEl, {
center,
center,
zoom: Number(props2.scale),
zoom: Number(props2.scale),
...
@@ -23457,7 +23496,22 @@ function useMap(props2, rootRef, emit2) {
...
@@ -23457,7 +23496,22 @@ function useMap(props2, rootRef, emit2) {
}
}
});
});
if (getIsBMap()) {
if (getIsBMap()) {
console.log("bmap的事件绑定是on??");
map2.addEventListener("click", () => {
trigger("tap", {}, {});
trigger("click", {}, {});
});
map2.addEventListener("dragstart", () => {
trigger("regionchange", {}, {
type: "begin",
causedBy: "gesture"
});
});
map2.addEventListener("dragend", () => {
trigger("regionchange", {}, extend({
type: "end",
causedBy: "drag"
}, getMapInfo2()));
});
} else {
} else {
const boundsChangedEvent = event.addListener(map2, "bounds_changed", () => {
const boundsChangedEvent = event.addListener(map2, "bounds_changed", () => {
boundsChangedEvent.remove();
boundsChangedEvent.remove();
...
...
packages/uni-h5/src/view/components/map/index.tsx
浏览文件 @
a34d87f8
...
@@ -160,6 +160,9 @@ function getLat(latLng: LatLng) {
...
@@ -160,6 +160,9 @@ function getLat(latLng: LatLng) {
if
(
'
getLat
'
in
latLng
)
{
if
(
'
getLat
'
in
latLng
)
{
return
latLng
.
getLat
()
return
latLng
.
getLat
()
}
else
{
}
else
{
if
(
getIsBMap
())
{
return
latLng
.
lat
}
return
latLng
.
lat
()
return
latLng
.
lat
()
}
}
}
}
...
@@ -168,6 +171,9 @@ function getLng(latLng: LatLng) {
...
@@ -168,6 +171,9 @@ function getLng(latLng: LatLng) {
if
(
'
getLng
'
in
latLng
)
{
if
(
'
getLng
'
in
latLng
)
{
return
latLng
.
getLng
()
return
latLng
.
getLng
()
}
else
{
}
else
{
if
(
getIsBMap
())
{
return
latLng
.
lng
}
return
latLng
.
lng
()
return
latLng
.
lng
()
}
}
}
}
...
@@ -300,7 +306,7 @@ function useMap(
...
@@ -300,7 +306,7 @@ function useMap(
const
center
=
getMapPosition
(
maps
,
state
.
latitude
,
state
.
longitude
)
const
center
=
getMapPosition
(
maps
,
state
.
latitude
,
state
.
longitude
)
const
event
=
const
event
=
(
maps
as
QQMaps
|
GoogleMaps
).
event
||
(
maps
as
AMap
.
NameSpace
).
Event
(
maps
as
QQMaps
|
GoogleMaps
).
event
||
(
maps
as
AMap
.
NameSpace
).
Event
console
.
log
(
'
event:
'
,
event
)
//
console.log('event:', event)
const
map
=
new
maps
.
Map
(
mapEl
,
{
const
map
=
new
maps
.
Map
(
mapEl
,
{
center
:
center
as
any
,
center
:
center
as
any
,
zoom
:
Number
(
props
.
scale
),
zoom
:
Number
(
props
.
scale
),
...
@@ -340,7 +346,32 @@ function useMap(
...
@@ -340,7 +346,32 @@ function useMap(
})
})
// 需在 bounds_changed 后触发 BoundsReady
// 需在 bounds_changed 后触发 BoundsReady
if
(
getIsBMap
())
{
if
(
getIsBMap
())
{
console
.
log
(
'
bmap的事件绑定是on??
'
)
// @ts-ignore
map
.
addEventListener
(
'
click
'
,
()
=>
{
trigger
(
'
tap
'
,
{}
as
Event
,
{})
trigger
(
'
click
'
,
{}
as
Event
,
{})
})
// @ts-ignore
map
.
addEventListener
(
'
dragstart
'
,
()
=>
{
trigger
(
'
regionchange
'
,
{}
as
Event
,
{
type
:
'
begin
'
,
causedBy
:
'
gesture
'
,
})
})
// @ts-ignore
map
.
addEventListener
(
'
dragend
'
,
()
=>
{
trigger
(
'
regionchange
'
,
{}
as
Event
,
extend
(
{
type
:
'
end
'
,
causedBy
:
'
drag
'
,
},
getMapInfo
()
)
)
})
}
else
{
}
else
{
const
boundsChangedEvent
=
event
.
addListener
(
const
boundsChangedEvent
=
event
.
addListener
(
map
,
map
,
...
...
packages/uni-h5/src/view/components/map/map-polygon/index.tsx
浏览文件 @
a34d87f8
...
@@ -127,7 +127,6 @@ export default /*#__PURE__*/ defineSystemComponent({
...
@@ -127,7 +127,6 @@ export default /*#__PURE__*/ defineSystemComponent({
return
return
}
}
if
(
getIsBMap
())
{
if
(
getIsBMap
())
{
console
.
log
(
'
polygon options:
'
,
polygonOptions
)
// @ts-ignore
// @ts-ignore
polygonIns
=
new
maps
.
Polygon
(
polygonOptions
.
path
,
polygonOptions
)
polygonIns
=
new
maps
.
Polygon
(
polygonOptions
.
path
,
polygonOptions
)
// @ts-ignore
// @ts-ignore
...
...
pnpm-lock.yaml
浏览文件 @
a34d87f8
lockfileVersion
:
'
6.0'
lockfileVersion
:
'
6.0'
settings
:
autoInstallPeers
:
true
excludeLinksFromLockfile
:
false
overrides
:
overrides
:
'
@babel/plugin-transform-block-scoping'
:
7.19.4
'
@babel/plugin-transform-block-scoping'
:
7.19.4
...
@@ -10917,7 +10921,3 @@ packages:
...
@@ -10917,7 +10921,3 @@ packages:
optionalDependencies
:
optionalDependencies
:
commander
:
9.5.0
commander
:
9.5.0
dev
:
true
dev
:
true
settings
:
autoInstallPeers
:
true
excludeLinksFromLockfile
:
false
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录