diff --git a/src/bundle/components/profile_v3/profile-measures_v3.vue b/src/bundle/components/profile_v3/profile-measures_v3.vue
index de368835..8b790c86 100644
--- a/src/bundle/components/profile_v3/profile-measures_v3.vue
+++ b/src/bundle/components/profile_v3/profile-measures_v3.vue
@@ -1,5 +1,4 @@
- (closeEvent_v3 = Date.now())"
- />
+
diff --git a/src/bundle/stores/profile-draw_v3.store.ts b/src/bundle/stores/profile-draw_v3.store.ts
index 2c362fa5..40a5c084 100644
--- a/src/bundle/stores/profile-draw_v3.store.ts
+++ b/src/bundle/stores/profile-draw_v3.store.ts
@@ -1,6 +1,6 @@
import { Ref, ref } from 'vue'
import { acceptHMRUpdate, defineStore } from 'pinia'
-import { Feature, Map } from 'ol'
+import { Map } from 'ol'
import { DrawnFeature } from '@/services/draw/drawn-feature'
import { ProfileData } from '@/components/common/graph/elevation-profile'
@@ -22,7 +22,7 @@ export const useProfileDrawv3Store = defineStore(
function setProfileData(
map: Map,
- feature: Feature & DrawnFeature,
+ feature: DrawnFeature,
profileData: ProfileData
) {
feature_v3.value = undefined
diff --git a/src/bundle/stores/profile-measures_v3.store.ts b/src/bundle/stores/profile-measures_v3.store.ts
index 9c2ffa06..8a9f5d19 100644
--- a/src/bundle/stores/profile-measures_v3.store.ts
+++ b/src/bundle/stores/profile-measures_v3.store.ts
@@ -1,6 +1,6 @@
import { Ref, ref } from 'vue'
import { acceptHMRUpdate, defineStore } from 'pinia'
-import { Feature, Map } from 'ol'
+import { Map } from 'ol'
import { DrawnFeature } from '@/services/draw/drawn-feature'
import { ProfileData } from '@/components/common/graph/elevation-profile'
@@ -28,7 +28,7 @@ export const useProfileMeasuresv3Store = defineStore(
function setProfileData(
map: Map,
- feature: Feature & DrawnFeature,
+ feature: DrawnFeature,
profileData: ProfileData
) {
feature_v3.value = undefined
diff --git a/src/components/feature-elevation-profile/feature-elevation-profile.vue b/src/components/feature-elevation-profile/feature-elevation-profile.vue
index ca5284eb..9fd4a6fd 100644
--- a/src/components/feature-elevation-profile/feature-elevation-profile.vue
+++ b/src/components/feature-elevation-profile/feature-elevation-profile.vue
@@ -84,6 +84,8 @@ watchEffect(() => {
if (props.feature && !props.feature.profileData) {
profileData.value = undefined // Force refresh the graph
props.feature?.getProfile().then(data => (profileData.value = data))
+ } else {
+ profileData.value = undefined
}
})
diff --git a/src/composables/map/profile-position.composable.ts b/src/composables/map/profile-position.composable.ts
index 31336f0f..90b8d9ec 100644
--- a/src/composables/map/profile-position.composable.ts
+++ b/src/composables/map/profile-position.composable.ts
@@ -10,7 +10,7 @@ import {
} from 'vue'
import { storeToRefs } from 'pinia'
import { Map, MapBrowserEvent } from 'ol'
-import { EventsKey, listen, ListenerFunction, unlistenByKey } from 'ol/events'
+import { EventsKey, listen, unlistenByKey } from 'ol/events'
import { LineString, Point } from 'ol/geom'
import GeometryLayout from 'ol/geom/GeometryLayout'
import { transform } from 'ol/proj'
@@ -51,6 +51,7 @@ export default function useProfilePosition(
const displayGeoMarker = ref(true) // deactivate geomarker when mode edition
const virtualLineProfile = new LineString([0, 0], GeometryLayout.XYM) // don't add to the map, it is used to compute the distance between the user cursor and the feature (represented by the virtual line)
const activePositioning = ref(true)
+ const throttledPointerMove = throttle(evt => onPointerMove(evt), 15) // Keep fn def as const for unlisten
let map: Map
let listenerIdPointerMove: EventsKey | undefined
@@ -58,7 +59,9 @@ export default function useProfilePosition(
onMounted(() => {
map = useMap().getOlMap()
createLayerFeaturePosition()
+ attachPointerMove()
})
+
onUnmounted(() => detachPointerMove())
watch(
@@ -75,7 +78,6 @@ export default function useProfilePosition(
watch(profileData, profileData => {
if (profileData) {
constructProfileLine(profileData)
- attachPointerMove()
}
})
@@ -130,20 +132,18 @@ export default function useProfilePosition(
*/
function attachPointerMove() {
if (listenerIdPointerMove === undefined) {
- listenerIdPointerMove = listen(
- map,
- 'pointermove',
- throttle(evt => onPointerMove(evt), 20)
- )
+ listenerIdPointerMove = listen(map, 'pointermove', throttledPointerMove)
}
}
/**
- * Unlisten 'pointermove' event on map
+ * Unlisten 'pointermove' event on map and remove geomarker
*/
function detachPointerMove() {
if (listenerIdPointerMove) {
unlistenByKey(listenerIdPointerMove)
+ listenerIdPointerMove = undefined
+
overlay?.removeGeoMarker()
}
}