Skip to content

Commit 939bdd9

Browse files
fix(geoLocation): handle differences in coordinates due to zooming
1 parent f3a5427 commit 939bdd9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/plugins/geoLocation/components/GeoLocation.ce.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,24 @@ const tooltipPosition = computed(() =>
4444
)
4545
4646
watch(center, () => {
47-
if (position.value !== center.value) {
47+
if (
48+
!position.value.length ||
49+
!center.value.length ||
50+
position.value[0] === undefined ||
51+
position.value[1] === undefined ||
52+
center.value[0] === undefined ||
53+
center.value[1] === undefined
54+
) {
55+
return
56+
}
57+
58+
const tolerance = 0.0001
59+
const coordinateDifference = Math.sqrt(
60+
Math.pow(position.value[0] - center.value[0], 2) +
61+
Math.pow(position.value[1] - center.value[1], 2)
62+
)
63+
64+
if (coordinateDifference > tolerance) {
4865
mapHasBeenMovedByUser.value = true
4966
}
5067
})

0 commit comments

Comments
 (0)