Skip to content

Commit

Permalink
fix: fixed #6 #5
Browse files Browse the repository at this point in the history
  • Loading branch information
yue1123 committed Jun 2, 2022
1 parent d50ad40 commit 0f1ddf4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
lat: 39.937
}"
:radius="300"
editing
enableEditing
/>
<Polyline
stroke-style="dashed"
Expand All @@ -54,7 +54,7 @@
stroke-color="#f90"
:stroke-opacity="1"
:stroke-weight="10"
editing
enableEditing
></Polyline>
<!-- <Polygon
:path="polylinePath"
Expand Down
45 changes: 19 additions & 26 deletions src/components/baidu-map/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@

<script setup lang="ts">
// FIXME: props 属性名字统一, 去掉enable
import {
inject,
defineProps,
withDefaults,
defineEmits,
watch,
onMounted,
onUnmounted,
provide,
nextTick
} from 'vue'
import { inject, defineProps, withDefaults, defineEmits, watch, onMounted, onUnmounted, provide, nextTick } from 'vue'
import useLife from '../../hooks/useLife'
import bindEvents, { Callback } from '../../utils/bindEvents'
Expand Down Expand Up @@ -213,21 +203,6 @@
'longpress'
])
const ak = props.ak || inject('baiduMapAk')
// 监听props变化
watch(() => props.zoom, setZoom)
watch(() => props.tilt, setTilt)
watch(() => props.heading, setHeading)
watch(() => props.center, setCenter)
watch(() => props.enableDragging, setDragging)
watch(() => props.enableInertialDragging, setInertialDragging)
watch(() => props.enableScrollWheelZoom, setScrollWheelZoom)
watch(() => props.enableContinuousZoom, setContinuousZoom)
watch(() => props.enableResizeOnCenter, setResizeOnCenter)
watch(() => props.enableDoubleClickZoom, setDoubleClickZoom)
watch(() => props.enableKeyboard, setKeyboard)
watch(() => props.enablePinchToZoom, setPinchToZoom)
watch(() => props.enableAutoResize, setAutoResize)
watch(() => props.mapType, setMapType)
// 获取地图SDK Script
function getMapScriptAsync() {
if (!window._BMap) {
Expand Down Expand Up @@ -262,13 +237,31 @@
})
setCenterAanZoom()
initMapOptions()
startWatchProps()
bindEvents(props, vueEmits, map)
if (!initd) {
initd = true
nextTick(() => ready(map))
}
})
}
function startWatchProps() {
// 监听props变化
watch(() => props.zoom, setZoom)
watch(() => props.tilt, setTilt)
watch(() => props.heading, setHeading)
watch(() => props.center, setCenter)
watch(() => props.enableDragging, setDragging)
watch(() => props.enableInertialDragging, setInertialDragging)
watch(() => props.enableScrollWheelZoom, setScrollWheelZoom)
watch(() => props.enableContinuousZoom, setContinuousZoom)
watch(() => props.enableResizeOnCenter, setResizeOnCenter)
watch(() => props.enableDoubleClickZoom, setDoubleClickZoom)
watch(() => props.enableKeyboard, setKeyboard)
watch(() => props.enablePinchToZoom, setPinchToZoom)
watch(() => props.enableAutoResize, setAutoResize)
watch(() => props.mapType, setMapType)
}
// 设置地图属性
function initMapOptions() {
const {
Expand Down
1 change: 1 addition & 0 deletions src/components/overlay/bm-circle/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
enableMassClear ? circle!.enableMassClear() : circle!.disableMassClear()
}
function setEditing(enableEditing: boolean): void {
console.log(enableEditing);
enableEditing ? circle!.enableEditing() : circle!.disableEditing()
}
</script>

0 comments on commit 0f1ddf4

Please sign in to comment.