Skip to content

Commit f23541a

Browse files
authored
Merge pull request #135 from Dataport/fix/geo-location-could-fail-map-init
fix GeoLocation failing map init on Safari<16
2 parents eb363f3 + 1b8cc2a commit f23541a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/plugins/GeoLocation/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## unpublished
44

55
- Fix: Only zoom to the user position if the user is currently in the extent of the map. The user position is no longer indicated when it's outside the map's extent.
6+
- Fix: The plugin would fail the map initialization procedure on Safari 15 and prior. This issue has been resolved by disabling the fail-fast feature for browsers not supporting `navigator.permissions.query`.
67

78
## 1.3.0
89

packages/plugins/GeoLocation/src/store/actions.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ const actions: PolarActionTree<GeoLocationState, GeoLocationGetters> = {
1818
setupModule({ getters, commit, dispatch }): void {
1919
dispatch('addMarkerLayer')
2020

21-
// NOTE: limited support across browsers
22-
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
23-
if (result.state === 'denied') {
24-
commit('setIsGeolocationDenied', true)
25-
}
26-
})
21+
// NOTE: limited support across browsers; nice but optional initially
22+
if (navigator.permissions?.query) {
23+
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
24+
if (result.state === 'denied') {
25+
commit('setIsGeolocationDenied', true)
26+
}
27+
})
28+
}
2729
if (getters.checkLocationInitially) {
2830
dispatch('track')
2931
}

0 commit comments

Comments
 (0)