添加自动缩放选项

This commit is contained in:
Shikong 2023-05-17 17:24:30 +08:00
parent 712e9afcf3
commit 5c7ee289ca

View File

@ -12,7 +12,7 @@
label="显示所有路径点" label="显示所有路径点"
v-model="options.showMarker" v-model="options.showMarker"
color="primary" color="primary"
@update:model-value="redrawMap" @update:model-value="toggleShowMarker"
keep-color keep-color
/> />
@ -24,6 +24,14 @@
keep-color keep-color
/> />
<q-toggle
label="自动缩放"
v-model="options.autoScaling"
color="primary"
@update:model-value="redrawMap"
keep-color
/>
<q-toggle <q-toggle
label="卫星地图" label="卫星地图"
v-model="layers.satellite.show" v-model="layers.satellite.show"
@ -129,6 +137,7 @@ const layers = reactive({
const options = reactive({ const options = reactive({
useHighAccuracyLocation: true, useHighAccuracyLocation: true,
showMarker: false, showMarker: false,
autoScaling: true,
}) })
const authModel = reactive({ const authModel = reactive({
@ -160,6 +169,13 @@ function login(){
}) })
} }
function toggleShowMarker(v){
if(v){
options.autoScaling = false
}
redrawMap()
}
function redrawMap(){ function redrawMap(){
clearMap() clearMap()
drawMap() drawMap()
@ -431,6 +447,9 @@ function drawMap(){
// }) // })
map.add(data.polylines) map.add(data.polylines)
setTimeout(()=>{ setTimeout(()=>{
if(!options.autoScaling){
return
}
if (data.polylines.length > 0) { if (data.polylines.length > 0) {
map.setFitView() map.setFitView()
} }