Skip to content

Commit

Permalink
feat: 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
yue1123 committed Nov 17, 2022
1 parent 99f501f commit a552547
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 11 deletions.
13 changes: 13 additions & 0 deletions docs/zh/overlay/label.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,21 @@ import { Label } from 'vue3-baidu-map-gl'
<Map
:minZoom="3"
>
<Marker
:zIndex="900"
:position="{ lat: 39.915185, lng: 116.400901 }"
:icon="{
imageUrl: 'https://cdn.jsdelivr.net/gh/yue1123/[email protected]/docs/public/logo.png',
imageSize: {
width: 100,
height: 100
},
}"
enableDragging
/>
<Label
:content="content"
:zIndex="-1"
:position="{lng: 116.404, lat: 39.915 }"
:style="{
color:'#fff',
Expand Down
2 changes: 1 addition & 1 deletion packages/components/overlay/bezierCurve/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
bindEvents(props, vueEmits, bezierCurve)
}
init()
// 监听值变化
watch(
() => props.path,
Expand All @@ -133,7 +134,6 @@
watch(() => props.strokeStyle, setStrokeStyle)
watch(() => props.enableMassClear, setMassClear)
init()
return cal
})
Expand Down
3 changes: 2 additions & 1 deletion packages/components/overlay/circle/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
bindEvents(props, vueEmits, circle)
ready(map, circle)
}
init()
// 监听值变化
watch(() => props.center, callWhenDifferentValue(setCenter), { deep: true })
watch(() => props.radius, setRadius)
Expand All @@ -161,7 +163,6 @@
watch(() => props.enableMassClear, setMassClear)
watch(() => props.enableEditing, setEditing)
init()
return cal
})
Expand Down
4 changes: 2 additions & 2 deletions packages/components/overlay/infowindow/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
bindEvents(props, vueEmits, infoWindow)
}
init()
ready(map, infoWindow)
// 监听值变化
watch(() => props.position, callWhenDifferentValue(setPosition), { deep: true })
watch(() => props.offset, callWhenDifferentValue(setOffset), { deep: true })
Expand All @@ -128,8 +130,6 @@
})
)
init()
ready(map, infoWindow)
if (props.modelValue) {
// 多个 infoWindow, 显示最后一个实例, 其他实例同步显隐状态
nextTick(() => {
Expand Down
14 changes: 11 additions & 3 deletions packages/components/overlay/label/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
* 标注的位置偏移值
*/
offset?: LabelOffset
/**
* 显示层级
*/
// zIndex: number
style?: LabelStyle
/**
* @default true
Expand Down Expand Up @@ -92,24 +96,28 @@
label.setStyle(style)
}
map.addOverlay(label)
// isDef(zIndex) && setZIndex(zIndex)
bindEvents(props, vueEmits, label)
}
init()
ready(map, label)
// 监听值变化
watch(() => props.position, callWhenDifferentValue(setPosition), { deep: true })
watch(() => props.offset, callWhenDifferentValue(setOffset), { deep: true })
watch(() => props.style, callWhenDifferentValue(setStyle), { deep: true })
watch(() => props.content, setContent)
watch(() => props.enableMassClear, setMassClear)
init()
ready(map, label)
// 在地图上添加点标记
return cal
})
provide('getOverlayInstance', () => label)
// function setZIndex(zIndex: number) {
// console.log('shezhi ')
// label.setZIndex(zIndex)
// }
function setPosition(position: LabelPosition) {
label.setPosition(new BMapGL.Point(position.lng, position.lat))
}
Expand Down
6 changes: 3 additions & 3 deletions packages/components/overlay/marker3d/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
setMassClear(enableMassClear)
bindEvents(props, vueEmits, marker3d)
}
init()
ready(map, marker3d)
// 监听值变化
watch(() => props.enableMassClear, setMassClear)
watch(() => props.position, callWhenDifferentValue(setPosition), { deep: true })
Expand All @@ -129,9 +132,6 @@
watch(() => props.height, setHeight)
watch(() => props.fillOpacity, setFillOpacity)
watch(() => props.fillColor, setFillColor)
init()
ready(map, marker3d)
return cal
})
Expand Down
2 changes: 1 addition & 1 deletion packages/components/overlay/polyline/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
ready(map, polyline)
}
init()
// 监听值变化
watch(
() => props.path,
Expand All @@ -148,7 +149,6 @@
watch(() => props.enableMassClear, setMassClear)
watch(() => props.enableEditing, setEditing)
init()
return cal
})
Expand Down

0 comments on commit a552547

Please sign in to comment.