[Violation] Only request geolocation information in response to a user gesture.

Hello!

I notice that the geolocation is having some small problems. If I open the browser console, I see the error

[Violation] Only request geolocation information in response to a user gesture.

image

The geolocation is achieved with a timer every 10 seconds executing

  geoLoc.GetGeolocation;

geoLoc is TWebGeoLocation

It looks like is working, but I'm concerned about the warning, because I'm planning a feature that is running on customer's tablets and if it stops working, the I am in big trouble if the warning becomes a more severe error in future browser updates.

I would kindly ask for help

Kind regards.

The warning "only request geolocation information in response to a user gesture" typically appears in web applications due to security and user privacy concerns. This warning is enforced by modern browsers when a website tries to access geolocation APIs without direct interaction from the user. Here’s a breakdown of the reason:

1. User Privacy

  • Geolocation APIs provide sensitive information about the user's location. Automatically accessing this data without explicit user consent can raise privacy concerns.
  • Requiring a user gesture (like clicking a button) ensures that the user explicitly consents to share their location information.

2. Prevent Abuse

  • Some malicious websites may attempt to collect location data without the user's knowledge, leading to abuse.
  • Enforcing a user gesture helps prevent such unauthorized attempts to access geolocation.

3. Improved User Experience

  • Prompting for location only after a user gesture creates a smoother user experience because the request appears as a result of their action, rather than an unexpected pop-up.
  • It prevents annoying location prompts that may confuse or frustrate the user.

4. Browser Policies

  • Modern browsers, such as Chrome and Firefox, have implemented stricter security policies that require a user action (like clicking a button) before accessing sensitive features such as:
    • Geolocation
    • Camera or microphone access
    • Notifications API