Skip to content

Commit 0a3be8c

Browse files
authored
Merge pull request #7373 from zoran995/3601-my-location-error
fix process error types when obtaining user location
2 parents 7bf2f92 + abea959 commit 0a3be8c

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#### next release (8.7.12)
44

55
- support URL parameters in a GetLegendGraphic request for a layer without a style configured
6+
- Enhanced error processing for obtaining user location
67
- [The next improvement]
78

89
#### 8.7.11 - 2024-12-18

lib/ReactViews/Map/MapNavigation/Items/MyLocation.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class MyLocation extends MapNavigationItemController {
154154
});
155155
}
156156

157-
handleLocationError(err: any) {
157+
handleLocationError(err: GeolocationPositionError) {
158158
const t = i18next.t.bind(i18next);
159159
let message = err.message;
160160
if (message && message.indexOf("Only secure origins are allowed") === 0) {
@@ -163,12 +163,19 @@ export class MyLocation extends MapNavigationItemController {
163163
const uri = new URI(window.location);
164164
const secureUrl = uri.protocol("https").toString();
165165
message = t("location.originError", { secureUrl: secureUrl });
166+
} else if (err.code === err.PERMISSION_DENIED) {
167+
message = t("location.permissionDenied");
168+
} else if (err.code === err.POSITION_UNAVAILABLE) {
169+
message = t("location.positionUnavailable");
170+
} else if (err.code === err.TIMEOUT) {
171+
message = t("location.timeout");
166172
}
167173
this.terria.raiseErrorToUser(
168174
new TerriaError({
169175
sender: this,
170176
title: t("location.errorGettingLocation"),
171-
message: message
177+
message: message,
178+
showDetails: false
172179
})
173180
);
174181
}

wwwroot/languages/en/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
"myLocation": "My Location",
6464
"location": "Location",
6565
"originError": "Your browser can only provide your location when using HTTPS. You may be able to use {{secureUrl}} instead.",
66-
"centreMap": "Centre map at your current location"
66+
"centreMap": "Centre map at your current location",
67+
"permissionDenied": "Permission denied to get your location. Please check your browser settings.",
68+
"positionUnavailable": "Your location information is unavailable.",
69+
"timeout": "Obtaining your location information took to long. Please try again later."
6770
},
6871
"splitterTool": {
6972
"errorTitle": "Failed to compare catalog item.",

0 commit comments

Comments
 (0)