File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
packages/viewer/src/store/modules/geolocation/utils Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -37,13 +37,25 @@ export default function handleNewGeolocationPosition(
3737 // Accuracy in in meter, so we don't need the decimal part and avoid dispatching event
3838 // if the accuracy did not change more than one metter
3939 const accuracy = round ( position . coords . accuracy , 0 )
40- if ( ! isEqual ( this . position , positionProjected ) || this . accuracy !== accuracy ) {
41- this . setGeolocationPosition ( positionProjected , dispatcher )
42- this . setGeolocationAccuracy ( accuracy , dispatcher )
43- }
40+
4441 // if tracking is active, we center the view of the map on the position received and change
4542 // to the proper zoom
43+ // IMPORTANT: Call setCenterIfInBounds BEFORE updating position to avoid setCenter disabling tracking
4644 if ( this . tracking ) {
4745 setCenterIfInBounds . call ( this , positionProjected , dispatcher )
46+ } else {
47+ log . debug ( {
48+ title : 'Geolocation store / handleNewPosition' ,
49+ titleColor : LogPreDefinedColor . Amber ,
50+ messages : [
51+ `[handleNewGeolocationPosition] Skipping setCenterIfInBounds - tracking is false` ,
52+ ] ,
53+ } )
54+ }
55+
56+ // Update position and accuracy after centering
57+ if ( ! isEqual ( this . position , positionProjected ) || this . accuracy !== accuracy ) {
58+ this . setGeolocationPosition ( positionProjected , dispatcher )
59+ this . setGeolocationAccuracy ( accuracy , dispatcher )
4860 }
4961}
You can’t perform that action at this time.
0 commit comments