HTML Tutorial

The language for building web pages.

HTML Geolocation

HTML Geolocation API

The HTML Geolocation API is used to get the geographical position of the user. Since this can compromise privacy, the position is not available unless the user approves it.

Methods:

  • getCurrentPosition() - Get current position once
  • watchPosition() - Track position changes
  • clearWatch() - Stop tracking

Position Properties:

  • coords.latitude
  • coords.longitude
  • coords.accuracy
  • coords.altitude
  • coords.speed

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics