HTML Geolocation API
Learn how the HTML Geolocation API works and how websites can access user location safely.
The Geolocation API allows websites to access user location.
Basic Example
<script>
navigator.geolocation.getCurrentPosition(
position => console.log(position.coords.latitude),
error => console.log(error)
);
</script>
Important Notes
- Requires user permission
- Works over HTTPS
- Accuracy depends on device
Was this helpful?
Thanks for your feedback!