Location

Location Service

Description

  • Geolocation Handling for Toolstation Web.

getCurrentLocation(): Promise<Geoposition>

  • Description: Requests the user's current geographical location using the browser’s Geolocation API.
  • Returns: A Promise that resolves with a Geoposition object containing:
    • latitude (as string)
    • longitude (as string)
  • Error Handling:
    • If the location fetch fails (e.g., permission denied, timeout), the error is:
      • Rejected via the promise.
      • Logged using $customClientErrorHandler with:
        • Severity: 'high'
        • Metadata: { locationServiceError: true }
        • Description: 'Location Service Error - trying to getCurrentLocation() using getCurrentLocation()'
  • Fallback: If geolocation is not supported by the browser, it rejects with a descriptive error message.

Copyright © 2026