@@ -18,7 +18,7 @@ import * as Proj from 'ol/proj'
1818import { transform as transformCoordinates } from 'ol/proj'
1919import VectorSource from 'ol/source/Vector'
2020import { defineStore } from 'pinia'
21- import { computed , ref } from 'vue'
21+ import { computed , ref , watch } from 'vue'
2222
2323import { useCoreStore } from '@/core/stores'
2424import { notifyUser } from '@/lib/notifyUser'
@@ -46,6 +46,8 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
4646 const lastBoundaryCheck = ref < boolean | symbol | null > ( null )
4747 const position = ref < number [ ] > ( [ ] )
4848
49+ let mapHasBeenMovedByUser = false
50+
4951 const configuration = computed <
5052 GeoLocationPluginOptions & { showTooltip : boolean ; zoomLevel : number }
5153 > ( ( ) =>
@@ -141,6 +143,7 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
141143
142144 /** Enable tracking of geo position */
143145 function track ( ) {
146+ mapHasBeenMovedByUser = false
144147 if ( isGeolocationDenied . value ) {
145148 onError ( {
146149 message : 'Geolocation API usage was denied by user or configuration.' ,
@@ -166,6 +169,15 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
166169 geolocation . value . on ( 'error' , onError )
167170 }
168171
172+ watch (
173+ ( ) => coreStore . center ,
174+ ( ) => {
175+ if ( position . value !== coreStore . center ) {
176+ mapHasBeenMovedByUser = true
177+ }
178+ }
179+ )
180+
169181 /**
170182 * Show error information and stop tracking if there are errors by tracking the position
171183 */
@@ -245,7 +257,8 @@ export const useGeoLocationStore = defineStore('plugins/geoLocation', () => {
245257
246258 if (
247259 ( configuration . value . keepCentered || ! hadPosition ) &&
248- lastBoundaryCheck . value
260+ lastBoundaryCheck . value &&
261+ ! mapHasBeenMovedByUser
249262 ) {
250263 coreStore . map . getView ( ) . setCenter ( coordinate )
251264 coreStore . map . getView ( ) . setZoom ( configuration . value . zoomLevel )
0 commit comments