Skip to content

Commit

Permalink
Merge pull request #135 from Dataport/fix/geo-location-could-fail-map…
Browse files Browse the repository at this point in the history
…-init

fix GeoLocation failing map init on Safari<16
  • Loading branch information
warm-coolguy authored Jun 24, 2024
2 parents eb363f3 + 1b8cc2a commit f23541a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/plugins/GeoLocation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## unpublished

- 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.
- 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`.

## 1.3.0

Expand Down
14 changes: 8 additions & 6 deletions packages/plugins/GeoLocation/src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ const actions: PolarActionTree<GeoLocationState, GeoLocationGetters> = {
setupModule({ getters, commit, dispatch }): void {
dispatch('addMarkerLayer')

// NOTE: limited support across browsers
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
if (result.state === 'denied') {
commit('setIsGeolocationDenied', true)
}
})
// NOTE: limited support across browsers; nice but optional initially
if (navigator.permissions?.query) {
navigator.permissions.query({ name: 'geolocation' }).then((result) => {
if (result.state === 'denied') {
commit('setIsGeolocationDenied', true)
}
})
}
if (getters.checkLocationInitially) {
dispatch('track')
}
Expand Down

0 comments on commit f23541a

Please sign in to comment.