Forma saysThe Geolocation API asks the user for their location — always permission-gated, never silent.
navigator.geolocation.getCurrentPosition(success, error) requests the device's coordinates. The browser shows a permission prompt; if the user allows, your success callback gets a position with coords.latitude and coords.longitude.
It can fail or be denied, so always pass an error callback. Use watchPosition for live tracking (and clearWatch to stop). Geolocation only works over HTTPS (or localhost) for privacy.