-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from Geoportail-Luxembourg/GSLUX-705_modify_f…
…eature_rebased2 Gslux 705 modify feature selection and sync between map and UI
- Loading branch information
Showing
12 changed files
with
101 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script setup lang="ts"></script> | ||
|
||
<template> | ||
<slot name="color"></slot> | ||
<slot name="size"></slot> | ||
<slot name="angle"></slot> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { watch } from 'vue' | ||
import { storeToRefs } from 'pinia' | ||
|
||
import useMap from '@/composables/map/map.composable' | ||
import { listen } from 'ol/events' | ||
import * as olArray from 'ol/array.js' | ||
import { getUid } from 'ol/util' | ||
import { useDrawStore } from '@/stores/draw.store' | ||
import { useAppStore } from '@/stores/app.store' | ||
|
||
export default function useDrawSelect() { | ||
const map = useMap().getOlMap() | ||
const appStore = useAppStore() | ||
const { activeFeatureId, drawnFeatures } = storeToRefs(useDrawStore()) | ||
|
||
listen(map, 'click', event => handleClick(event)) | ||
|
||
watch(activeFeatureId, (newId, oldId) => { | ||
drawnFeatures.value | ||
.filter(f => getUid(f) == oldId) | ||
.forEach(oldFeature => { | ||
oldFeature.selected = false | ||
oldFeature.changed() | ||
}) | ||
drawnFeatures.value | ||
.filter(f => getUid(f) == newId) | ||
.forEach(newFeature => { | ||
newFeature.selected = true | ||
newFeature.changed() | ||
}) | ||
}) | ||
|
||
const handleClick = function (event: any) { | ||
const pixel = event.pixel | ||
|
||
const feature = map.forEachFeatureAtPixel( | ||
pixel, | ||
feature => { | ||
const featureMatch = olArray.includes(drawnFeatures.value, feature) | ||
if (featureMatch) { | ||
appStore.toggleMyMapsOpen(true) | ||
activeFeatureId.value = getUid(feature) | ||
|
||
return | ||
} | ||
}, | ||
{ | ||
hitTolerance: 5, | ||
} | ||
) | ||
|
||
if (feature) { | ||
return | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
src/services/state-persistor/state-persistor-features.mapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters