Skip to content

Commit

Permalink
fix(map): Load Atlases on map only at first mount
Browse files Browse the repository at this point in the history
  • Loading branch information
0live committed Jan 15, 2025
1 parent 255c681 commit ca57e3e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vue/src/services/qgisMap/QgisMapMaplibreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export class QgisMapMaplibreService {
}
})

// Otherwise the event will be triggered as much time as the layer has been added to the map
// Check if the layer has been already added to the map
// if not the event will be triggered as much time as the layer has been added to the map
if (firstAdd) {
map?.on('moveend', () => {
console.log('moveend')
try {
QgisMapMaplibreService.updateMapImageSourceCoordinates(
map as maplibregl.Map,
Expand Down
2 changes: 2 additions & 0 deletions vue/src/stores/myMapStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const useMyMapStore = defineStore(StoresList.MY_MAP, () => {
const projectLayer: Ref<Layer | null> = ref(null)
const projectSubLayers: Ref<Layer[]> = ref([])

const atlasesAlreadyInitialized: Ref<boolean> = ref(false)
const atlasThematicMaps: Ref<AtlasMap[]> = ref([])
let alreadyAddedImageSources: string[] = [] //Used to avoid triggering maplibre event as much time as the layer has been added to the map
function updateAtlasLayersVisibility(qgismapId: string) {
Expand All @@ -43,6 +44,7 @@ export const useMyMapStore = defineStore(StoresList.MY_MAP, () => {
projectSubLayers,
resourceLayer,
resourceSubLayers,
atlasesAlreadyInitialized,
atlasThematicMaps,
updateAtlasLayersVisibility
}
Expand Down
5 changes: 4 additions & 1 deletion vue/src/views/map/components/Atlases/MyMapAtlas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ const hideDetails = ref(true)
const myMapStore = useMyMapStore()
onMounted(() => {
myMapStore.atlasThematicMaps.push(...AtlasService.setAtlasLayers(props.atlas))
if (!myMapStore.atlasesAlreadyInitialized) {
myMapStore.atlasThematicMaps.push(...AtlasService.setAtlasLayers(props.atlas))
myMapStore.atlasesAlreadyInitialized = true
}
})
const updateThematicData = (qgismapId: string) => {
Expand Down

0 comments on commit ca57e3e

Please sign in to comment.