Overview
The Geolocation API provides the latitude and longitude of the device, often along with altitude, heading, and speed. It can use a variety of sources, including GPS, Wi-Fi, and IP address, to determine location.
Key Methods
getCurrentPosition(): Retrieves the current location once.watchPosition(): Continuously monitors the location and triggers a callback when it changes.
Privacy
This is a highly sensitive API. Browsers will always prompt the user for permission, and it is only available in secure contexts (HTTPS). Users can also choose to provide 'approximate' rather than 'precise' location in some environments.