Skip to content

Commit 7617c4e

Browse files
Map zoom
1 parent 5b1c4b6 commit 7617c4e

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/modules/documentExecution/dashboard/widget/MapWidget/LeafletWrapper.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import useAppStore from '@/App.store'
1414
import i18n from '@/App.i18n'
1515
import { emitter } from '@/modules/documentExecution/dashboard/DashboardHelpers'
1616
import { clearLayersCache, switchLayerVisibility } from './visibility/MapVisibilityHelper'
17-
import { ISelection, IVariable } from '../../Dashboard'
17+
import { ISelection, IVariable, IWidget } from '../../Dashboard'
1818
1919
//#region inlined leaflet-layervisibility
2020
function validateFilter(filterFunc) {
@@ -112,14 +112,26 @@ const resizeMap = () => {
112112
}
113113
}
114114
115+
const getMapZoomValue = (widgetModel: IWidget | undefined): number => {
116+
const defaultZoom = 10
117+
118+
const zoom = widgetModel?.settings?.configuration?.map?.zoom
119+
const autoCentering = widgetModel?.settings?.configuration?.map?.autoCentering
120+
121+
if (autoCentering) return defaultZoom
122+
123+
const parsedZoom = parseInt(zoom)
124+
return isNaN(parsedZoom) ? defaultZoom : parsedZoom
125+
}
126+
115127
onMounted(async () => {
116128
emitter.on('widgetResized', resizeMap)
117129
118130
loadVariables()
119131
120132
map = L.map(mapId, {
121133
center: navigator && !props.widgetModel.settings?.configuration?.map?.autoCentering ? await getCoords() : [0, 0],
122-
zoom: parseInt(props.widgetModel.settings?.configuration?.map?.zoom) || 10,
134+
zoom: getMapZoomValue(props.widgetModel),
123135
attributionControl: false
124136
})
125137

src/modules/documentExecution/dashboard/widget/WidgetEditor/WidgetEditorSettingsTab/MapWidget/configuration/MapBaseLayerSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div v-if="mapSettings">
33
<div class="row q-mx-md q-pb-lg items-center">
4-
<q-input class="col" type="number" v-model="mapSettings.zoom" max="20" min="1" :label="$t('dashboard.widgetEditor.map.baseLayer.zoom')" />
4+
<q-input class="col" type="number" v-model="mapSettings.zoom" max="20" min="1" :label="$t('dashboard.widgetEditor.map.baseLayer.zoom')" :disable="mapSettings.autoCentering" />
55
<q-toggle class="col" v-model="mapSettings.showScale" :label="$t('dashboard.widgetEditor.map.baseLayer.showScale')" />
66
<q-toggle class="col" v-model="mapSettings.autoCentering" :label="$t('dashboard.widgetEditor.map.baseLayer.autoCentering')" />
77
</div>

0 commit comments

Comments
 (0)