W3C
Editor's
Draft
05
December
2025
Copyright
©
2025
2026
World
Wide
Web
Consortium
.
W3C
®
liability
,
trademark
and
permissive
document
license
rules
apply.
Geolocation provides access to geographical location information associated with the hosting device.
This
section
describes
the
status
of
this
document
at
the
time
of
its
publication.
A
list
of
current
W3C
publications
and
the
latest
revision
of
this
technical
report
can
be
found
in
the
W3C
standards
and
drafts
index
.
Permalink
Referenced
in:
§
6.5
Request
a
position
§
6.6
Acquire
a
position
§
11.
Permissions
policy
Permalink
Referenced
in:
§
1.
Introduction
§
3.1
User
consent
§
7.2
timeout
member
Permalink
exported
IDL
Referenced
in:
§
5.
Extensions
to
the
Navigator
interface
§
A.
IDL
Index
Permalink
exported
Referenced
in:
§
5.
Extensions
to
the
Navigator
interface
§
6.1
Internal
slots
§
6.5
Request
a
position
§
12.
Emulation
§
A.
IDL
Index
Permalink
exported
Referenced
in:
§
6.
Geolocation
interface
and
callbacks
(2)
§
6.5
Request
a
position
§
6.6
Acquire
a
position
§
8.5
Task
sources
§
A.
IDL
Index
(2)
Permalink
exported
Referenced
in:
§
6.
Geolocation
interface
and
callbacks
(2)
§
6.5
Request
a
position
§
6.6
Acquire
a
position
§
6.7
Call
back
with
error
§
8.5
Task
sources
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
6.1
Internal
slots
§
6.6
Acquire
a
position
(2)
(3)
Permalink
Referenced
in:
§
6.3
watchPosition()
method
§
6.4
clearWatch()
method
§
6.5
Request
a
position
§
6.6
Acquire
a
position
Permalink
exported
IDL
Referenced
in:
§
1.
Introduction
§
2.4
Handling
errors
§
3.1
User
consent
§
6.
Geolocation
interface
and
callbacks
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
1.
Introduction
§
2.4
Handling
errors
§
3.1
User
consent
§
6.
Geolocation
interface
and
callbacks
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
2.3
Stop
watching
a
position
§
6.
Geolocation
interface
and
callbacks
§
A.
IDL
Index
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
§
6.3
watchPosition()
method
§
8.5
Task
sources
§
10.1
Constants
§
D.
Change
log
Permalink
Referenced
in:
§
1.
Introduction
§
2.6
Using
timeout
§
6.5
Request
a
position
(2)
§
7.2
timeout
member
(2)
§
10.1
Constants
(2)
§
D.
Change
log
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
§
6.3
watchPosition()
method
§
6.5
Request
a
position
(2)
(3)
§
6.6
Acquire
a
position
(2)
(3)
(4)
§
10.2
code
attribute
Permalink
exported
IDL
Referenced
in:
§
1.
Introduction
§
2.6
Using
timeout
§
6.
Geolocation
interface
and
callbacks
(2)
§
6.5
Request
a
position
§
6.6
Acquire
a
position
§
7.
PositionOptions
dictionary
§
A.
IDL
Index
(2)
(3)
Permalink
exported
IDL
Referenced
in:
§
1.
Introduction
§
6.6
Acquire
a
position
(2)
(3)
(4)
(5)
§
7.
PositionOptions
dictionary
§
8.4
Internal
slots
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
2.6
Using
timeout
§
6.6
Acquire
a
position
§
7.
PositionOptions
dictionary
§
7.2
timeout
member
(2)
(3)
§
10.1
Constants
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
1.
Introduction
§
6.6
Acquire
a
position
(2)
§
7.
PositionOptions
dictionary
§
A.
IDL
Index
Permalink
exported
Referenced
in:
§
1.
Introduction
§
6.
Geolocation
interface
and
callbacks
§
6.1
Internal
slots
§
8.3
toJSON()
method
(2)
§
8.4
Internal
slots
(2)
§
9.6
Constructing
a
GeolocationPosition
(2)
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
8.
GeolocationPosition
interface
§
9.6
Constructing
a
GeolocationPosition
(2)
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
6.6
Acquire
a
position
§
8.
GeolocationPosition
interface
§
9.6
Constructing
a
GeolocationPosition
(2)
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
8.
GeolocationPosition
interface
§
A.
IDL
Index
Permalink
Referenced
in:
§
6.6
Acquire
a
position
§
9.6
Constructing
a
GeolocationPosition
(2)
Permalink
Referenced
in:
§
6.6
Acquire
a
position
(2)
(3)
§
6.7
Call
back
with
error
Permalink
exported
IDL
Referenced
in:
§
8.
GeolocationPosition
interface
§
9.
GeolocationCoordinates
interface
§
9.5
toJSON()
method
(2)
§
9.6
Constructing
a
GeolocationPosition
(2)
(3)
§
12.
Emulation
(2)
§
A.
IDL
Index
(2)
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
(2)
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
9.6
Constructing
a
GeolocationPosition
(2)
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
9.
GeolocationCoordinates
interface
§
A.
IDL
Index
Permalink
Referenced
in:
§
6.6
Acquire
a
position
(2)
(3)
§
8.4
Internal
slots
Permalink
exported
IDL
Referenced
in:
§
1.
Introduction
§
2.4
Handling
errors
§
6.
Geolocation
interface
and
callbacks
§
6.6
Acquire
a
position
§
6.7
Call
back
with
error
§
10.
GeolocationPositionError
interface
§
10.3
message
attribute
(2)
§
12.
Emulation
(2)
§
A.
IDL
Index
(2)
Permalink
exported
IDL
Referenced
in:
§
6.5
Request
a
position
(2)
(3)
§
6.6
Acquire
a
position
§
10.
GeolocationPositionError
interface
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
6.2
getCurrentPosition()
method
§
6.3
watchPosition()
method
§
6.6
Acquire
a
position
§
10.
GeolocationPositionError
interface
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
6.6
Acquire
a
position
§
10.
GeolocationPositionError
interface
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
6.6
Acquire
a
position
§
6.7
Call
back
with
error
§
10.
GeolocationPositionError
interface
§
10.3
message
attribute
(2)
§
A.
IDL
Index
Permalink
exported
IDL
Referenced
in:
§
10.
GeolocationPositionError
interface
§
10.3
message
attribute
§
A.
IDL
Index
Permalink
Referenced
in:
§
12.
Emulation
(2)
Permalink
exported
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
6.6
Acquire
a
position
Permalink
Referenced
in:
§
6.6
Acquire
a
position
§
8.
GeolocationPosition
interface
§
9.6
Constructing
a
GeolocationPosition
(2)
§
A.
IDL
Index
Permalink
Referenced
in:
§
2.7
Enabling
the
API
in
third-party
contexts
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
(2)
§
6.3
watchPosition()
method
(2)
§
6.5
Request
a
position
§
12.
Emulation
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
§
6.3
watchPosition()
method
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
(2)
§
6.3
watchPosition()
method
(2)
§
6.5
Request
a
position
Permalink
Referenced
in:
§
2.7
Enabling
the
API
in
third-party
contexts
§
6.5
Request
a
position
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
12.
Emulation
Permalink
Referenced
in:
§
3.4
Checking
permission
to
use
the
API
Permalink
Referenced
in:
§
5.
Extensions
to
the
Navigator
interface
§
A.
IDL
Index
Permalink
Referenced
in:
§
12.
Emulation
Permalink
Referenced
in:
§
6.5
Request
a
position
(2)
§
10.1
Constants
(2)
Permalink
Referenced
in:
§
3.4
Checking
permission
to
use
the
API
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
6.6
Acquire
a
position
(2)
(3)
§
6.7
Call
back
with
error
Permalink
Referenced
in:
§
3.4
Checking
permission
to
use
the
API
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
(2)
§
6.3
watchPosition()
method
(2)
§
6.5
Request
a
position
§
12.
Emulation
Permalink
Referenced
in:
§
8.5
Task
sources
Permalink
Referenced
in:
§
12.
Emulation
Permalink
Referenced
in:
§
12.
Emulation
(2)
Permalink
Referenced
in:
§
6.5
Request
a
position
(2)
(3)
Permalink
Referenced
in:
§
6.3
watchPosition()
method
Permalink
Referenced
in:
§
6.5
Request
a
position
§
6.6
Acquire
a
position
Permalink
Referenced
in:
§
9.6
Constructing
a
GeolocationPosition
Permalink
Referenced
in:
§
6.3
watchPosition()
method
Permalink
Referenced
in:
§
6.1
Internal
slots
Permalink
Referenced
in:
§
6.1
Internal
slots
Permalink
Referenced
in:
§
6.6
Acquire
a
position
(2)
§
9.6
Constructing
a
GeolocationPosition
(2)
Permalink
Referenced
in:
§
6.4
clearWatch()
method
§
6.5
Request
a
position
(2)
(3)
Permalink
Referenced
in:
§
3.4
Checking
permission
to
use
the
API
Permalink
Referenced
in:
§
3.1
User
consent
(2)
Permalink
Referenced
in:
§
6.6
Acquire
a
position
Permalink
Referenced
in:
§
3.1
User
consent
§
3.4
Checking
permission
to
use
the
API
§
6.6
Acquire
a
position
Permalink
Referenced
in:
§
3.1
User
consent
(2)
(3)
(4)
§
3.4
Checking
permission
to
use
the
API
(2)
Permalink
Referenced
in:
§
3.4
Checking
permission
to
use
the
API
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
3.4
Checking
permission
to
use
the
API
(2)
Permalink
Referenced
in:
§
3.1
User
consent
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
3.1
User
consent
Permalink
Referenced
in:
§
6.5
Request
a
position
Permalink
Referenced
in:
§
11.
Permissions
policy
Permalink
Referenced
in:
§
2.7
Enabling
the
API
in
third-party
contexts
§
11.
Permissions
policy
Permalink
Referenced
in:
§
11.
Permissions
policy
Permalink
Referenced
in:
§
7.
PositionOptions
dictionary
§
8.4
Internal
slots
§
A.
IDL
Index
Permalink
Referenced
in:
§
7.
PositionOptions
dictionary
(2)
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
8.
GeolocationPosition
interface
§
9.
GeolocationCoordinates
interface
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
10.
GeolocationPositionError
interface
§
A.
IDL
Index
Permalink
Referenced
in:
§
6.6
Acquire
a
position
(2)
(3)
(4)
(5)
(6)
(7)
§
9.
GeolocationCoordinates
interface
(2)
(3)
(4)
(5)
(6)
(7)
§
A.
IDL
Index
(2)
(3)
(4)
(5)
(6)
(7)
Permalink
Referenced
in:
§
6.
Geolocation
interface
and
callbacks
§
8.
GeolocationPosition
interface
§
9.
GeolocationCoordinates
interface
§
10.
GeolocationPositionError
interface
§
A.
IDL
Index
(2)
(3)
(4)
Permalink
Referenced
in:
§
6.6
Acquire
a
position
(2)
(3)
§
6.7
Call
back
with
error
Permalink
Referenced
in:
§
6.
Geolocation
interface
and
callbacks
(2)
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
8.
GeolocationPosition
interface
§
9.
GeolocationCoordinates
interface
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
5.
Extensions
to
the
Navigator
interface
§
A.
IDL
Index
Permalink
Referenced
in:
§
8.
GeolocationPosition
interface
§
9.
GeolocationCoordinates
interface
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
6.2
getCurrentPosition()
method
(2)
(3)
§
6.3
watchPosition()
method
(2)
(3)
§
6.4
clearWatch()
method
§
6.6
Acquire
a
position
(2)
(3)
(4)
(5)
Permalink
Referenced
in:
§
6.
Geolocation
interface
and
callbacks
(2)
(3)
(4)
§
A.
IDL
Index
(2)
(3)
(4)
Permalink
Referenced
in:
§
6.1
Internal
slots
§
6.3
watchPosition()
method
§
7.
PositionOptions
dictionary
(2)
§
A.
IDL
Index
(2)
Permalink
Referenced
in:
§
6.7
Call
back
with
error
§
10.
GeolocationPositionError
interface
(2)
(3)
(4)
§
A.
IDL
Index
(2)
(3)
(4)
Since
this
specification
became
a
W3C
Recommendation
on
01
September
2022,
the
following
substantive
additions
and/or
corrections
have
been
proposed:
Correction:
Clarify
that
only
the
emulated
error
code
is
used
(
#187
)
Addition:
support
geolocation
emulation
(
#183
)
Correction:
Use
null
instead
of
NaN
when
stationary
(
#173
)
Correction:
Update
acquisition
algorithm
to
define
data
types
and
han…
Addition:
Define
units
for
accuracy
(
#162
)
Correction:
check
for
non-secure
contexts
(
#157
)
Addition:
expose
.toJSON()
on
GeolocationCoordinates
+
GeolocationPos…
Correction:
Clarify
units
and
reference
geodetic
system
for
latitude
…
A
more
detailed
list
of
changes
can
be
found
in
section
D.
Change
log
.
Reviewers
of
the
document
can
identify
candidate
additions
and/or
corrections
by
their
distinctive
styling
in
the
document.
This document was published by the Devices and Sensors Working Group and the Web Applications Working Group as an Editor's Draft.
Publication as an Editor's Draft does not imply endorsement by W3C and its Members.
This
is
a
draft
document
and
may
be
updated,
replaced,
or
obsoleted
by
other
documents
at
any
time.
It
is
inappropriate
to
cite
this
document
as
other
than
a
work
in
progress.
Future
updates
to
this
upcoming
Recommendation
may
incorporate
new
features
.
This document was produced by groups operating under the W3C Patent Policy . W3C maintains a public list of any patent disclosures (Devices and Sensors Working Group) and a public list of any patent disclosures (Web Applications Working Group) made in connection with the deliverables of each group; these pages also include instructions for disclosing a patent. An individual who has actual knowledge of a patent that the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy .
This document is governed by the 18 August 2025 W3C Process Document .
This section is non-normative.
Geolocation
defines
a
high-level
interface
to
location
information
associated
only
with
the
device
hosting
the
implementation.
Common
sources
of
location
information
include
Global
Positioning
System
(GPS)
and
location
inferred
from
network
signals
such
as
IP
address,
RFID,
WiFi
and
Bluetooth
MAC
addresses,
and
GSM/CDMA
cell
IDs,
as
well
as
user
input.
The
API
itself
is
agnostic
of
the
underlying
location
information
sources,
source
s,
and
no
guarantee
is
given
that
the
API
returns
the
device's
actual
location.
This specification provides two ways for users to share their location: a precise position and an approximate position .
A precise position is a position returned by the underlying location information source . By default, any location data is considered precise, regardless of its accuracy estimate, unless it has been explicitly coarsened by an approximate location information source to be an approximate position .
An approximate position is a less precise, privacy-preserving representation of the user's location. Instead of providing precise coordinates, an approximate location information source can returns a location that is intentionally coarsened to a larger area, such as the nearest city, postal code, or a predefined region. This is often sufficient for applications that don't need to know the user's precise position , for example, a weather application that only needs a city-level location. By sharing an approximate position , users can still get the benefit of a location-aware application without revealing their precise position .
An approximate location information source is a location information source that returns positions that have been intentionally obfuscated to make it more difficult to recover the true location.
If
an
end
user
grants
permission
,
permission,
Geolocation
:
GeolocationPosition
interface.
getCurrentPosition
()
method
and
the
ability
to
receive
updates
for
when
the
position
of
the
hosting
device
significantly
changes
via
the
watchPosition
()
method.
PositionOptions
's
maximumAge
,
allows
an
application
to
request
a
cached
position
whose
age
is
no
greater
than
a
specified
value
(only
the
last
position
is
cached).
GeolocationPositionError
,
that
have
occurred
while
acquiring
a
position
.
enableHighAccuracy
,
supports
requesting
"high
accuracy"
position
data,
though
the
request
can
be
ignored
by
the
user
agent.
This section is non-normative.
This specification is limited to providing a scripting API for retrieving geographic position information associated with a hosting device. The geographic position information is provided in terms of World Geodetic System coordinates [ WGS84 ]. It does not include providing a markup language of any kind, nor does it include defining a new URL scheme for building URLs that identify geographic locations.
This section is non-normative.
The API is designed to enable both "one-shot" position requests and repeated position updates. The following examples illustrate common use cases.
This section is non-normative.
Request
the
user's
current
location.
If
the
user
allows
it,
you
grants
permission,
the
API
will
get
back
return
a
position
object.
The
website
can
influence
the
position's
accuracy
by
using
the
PositionOptions
dictionary's
accuracyMode
member.
By
default,
the
user
agent
will
provide
a
"
precise
"
location.
However,
a
website
can
request
an
approximate
position
by
setting
accuracyMode
to
"
approximate
",
which
helps
protect
user
privacy
if
high
accuracy
is
not
required.
This section is non-normative.
Request the ability to watch user's current location. If the user allows it, you will get back continuous updates of the user's position.
This section is non-normative.
Stop
watching
for
position
changes
by
calling
the
clearWatch
()
method.
This section is non-normative.
When
an
error
occurs,
the
second
argument
of
the
watchPosition
()
or
getCurrentPosition
()
method
gets
called
with
a
GeolocationPositionError
error,
which
can
help
you
figure
out
what
might
have
gone
wrong.
This section is non-normative.
By
default,
the
API
always
attempts
to
return
a
cached
position
so
long
as
it
has
a
previously
acquired
position.
position
that
matches
the
requested
accuracyMode
.
In
this
example,
we
accept
a
precise
position
whose
age
is
no
greater
than
10
minutes.
If
the
user
agent
does
not
have
a
fresh
enough
cached
position
object,
object
of
the
correct
accuracy,
it
automatically
acquires
a
new
position.
Similarly, you can request a cached approximate position.
This section is non-normative.
If
you
require
location
information
in
a
time
sensitive
manner,
you
can
use
the
PositionOptions
timeout
member
to
limit
the
amount
of
time
you
are
willing
to
wait
to
acquire
a
position
.
This section is non-normative.
The
default
allowlist
of
'self'
allows
API
usage
in
same-origin
nested
frames
but
prevents
third-party
content
from
using
the
API.
allow
="geolocation"
or
allow
="geolocation-approximate"
attribute
to
an
iframe
geolocation
is
allowed,
geolocation-approximate
is
also
implicitly
allowed.
Alternatively,
the
API
can
be
disabled
in
a
first-party
context
by
specifying
an
HTTP
response
header:
header.
Disabling
geolocation-approximate
will
also
disable
geolocation
.
See
Permissions
Policy
for
more
details
about
the
Permissions-Policy
HTTP
header.
This section is non-normative.
The API defined in this specification is used to retrieve the geographic location of a hosting device. In almost all cases, this information also discloses the location of the user of the device, thereby potentially compromising the user's privacy.
To
mitigate
this
privacy
risk,
this
specification
introduces
the
accuracyMode
option,
which
allows
the
application
to
request
an
approximate
position
.
This
allows
applications
to
function
without
needing
the
user's
precise
position
,
thus
offering
a
more
privacy-friendly
alternative.
When
an
application
requests
an
approximate
position
,
the
user
agent
can
provide
a
less
precise
location
that
still
meets
the
application's
needs
while
protecting
the
user's
precise
position
.
Even
when
a
precise
position
is
requested,
the
user
agent
can
provide
an
approximate
position
instead,
for
example,
if
the
user
has
only
granted
permission
for
approximate
accuracy.
This section is non-normative.
Geolocation
is
a
uses
the
powerful
feature
that
requires
s
"geolocation-approximate"
and
"geolocation"
,
which
require
express
permission
from
an
end-user
before
any
location
data
is
shared
with
a
web
application.
This
requirement
is
normatively
enforced
by
the
check
request
permission
to
use
steps
algorithm,
which
is
customized
for
precise
location
by
the
request
precise
geolocation
permission
steps,
on
which
the
getCurrentPosition
()
and
watchPosition
()
methods
rely.
User
agents
with
support
for
approximate
position
are
strongly
encouraged
to
allow
the
user
to
choose
between
sharing
a
precise
position
or
an
approximate
position
.
This
choice
gives
users
more
control
over
their
privacy,
allowing
them
to
share
a
less
precise
location
when
they
are
not
comfortable
sharing
their
precise
position
.
An end-user will generally give express permission through a user interface, which usually presents a range of permission lifetimes that the end-user can choose from. The choice of lifetimes vary across user agents, but they are typically time-based (e.g., "a day"), or until browser is closed, or the user might even be given the choice for the permission to be granted indefinitely. The permission lifetimes dictate how long a user agent grants a permission before that permission is automatically reverted back to its default permission state , prompting the end-user to make a new choice upon subsequent use.
Although
the
granularity
of
the
permission
lifetime
varies
across
user-agents,
this
specification
urges
user
agents
to
limit
the
lifetime
to
a
single
browsing
session
by
default
(see
3.4
Checking
permission
to
use
the
API
Geolocation
permissions
for
normative
requirements).
This section is non-normative.
This section applies to "recipients", which generally means developers utilizing Geolocation . Although it's impossible for the user agent, or this specification, to enforce these requirements, developers need to read this section carefully and do their best to adhere to the suggestions below. Developers need to be aware that there might be privacy laws in their jurisdictions that can govern the usage and access to users' location data.
Recipients ought to only request position information when necessary, and only use the location information for the task for which it was provided to them. Recipients ought to dispose of location information once that task is completed, unless expressly permitted to retain it by the user. Recipients need to also take measures to protect this information against unauthorized access. If location information is stored, users need to be allowed to update and delete this information.
In
line
with
this
principle,
recipients
are
strongly
encouraged
to
request
the
lowest
level
of
location
accuracy
that
is
sufficient
for
their
application's
functionality.
For
instance,
if
an
application
only
needs
to
know
the
user's
city,
it
can
respect
user
privacy
by
requesting
an
approximate
position
by
setting
the
accuracyMode
option
to
"approximate"
.
This
practice
of
data
minimization
is
a
key
aspect
of
respecting
user
privacy.
The recipients of location information need to refrain from retransmitting the location information without the user’s express permission. Care needs to be taken when retransmitting and the use of encryption is encouraged.
Recipients ought to clearly and conspicuously disclose the fact that they are collecting location data, the purpose for the collection, how long the data is retained, how the data is secured, how the data is shared if it is shared, how users can access, update and delete the data, and any other choices that users have with respect to the data. This disclosure needs to include an explanation of any exceptions to the guidelines listed above.
This section is non-normative.
Implementers are advised to consider the following aspects that can negatively affect the privacy of their users: in certain cases, users can inadvertently grant permission to the user agent to disclose their location to websites. In other cases, the content hosted at a certain URL changes in such a way that the previously granted location permissions no longer apply as far as the user is concerned. Or the users might simply change their minds.
Predicting or preventing these situations is inherently difficult. Mitigation and in-depth defensive measures are an implementation responsibility and not prescribed by this specification. However, in designing these measures, implementers are advised to enable user awareness of location sharing, and to provide access to user interfaces that enable revocation of permissions.
Geolocation
is
a
default
defines
two
powerful
feature
features
identified
by
the
name
s
"geolocation"
(for
precise
location)
and
.
"geolocation-approximate"
(for
approximate
location).
When
checking
is
a
default
powerful
feature
,
while
"geolocation-approximate"
is
a
powerful
feature
with:
"geolocation"
GeolocationPermissionStatus
: WebIDL[Exposed=(Window,Worker)]
interface GeolocationPermissionStatus : PermissionStatus {
readonly attribute AccuracyMode? accuracyMode;
};
PermissionDescriptor
permissionDesc
and
a
GeolocationPermissionStatus
status
,
runs
the
PermissionDescriptor
with
name
set
to
"geolocation-approximate"
.
state
to
appxorimatePermissionState
.
state
is
equal
to
"granted"
,
set
status
's
accuracyMode
to
"
precise
"
if
also
permissionDesc
's
permission
state
is
"granted"
or
to
"
approximate
"
otherwise.
To
request
precise
geolocation
permission
,
the
user
agent
MAY
MUST
suggest
time-based
permission
run
the
following
steps.
PermissionDescriptor
name
set
to
"geolocation"
.
GeolocationPermissionStatus
status
.
state
PermissionDescriptor
with
name
set
to
"geolocation-approximate"
.
PermissionStatus
approximateStatus
.
state
is
"granted"
,
request
permission
to
use
preciseLocationDescriptor
.
Otherwise,
request
permission
to
use
approximateLocationDescriptor
and
request
permission
to
use
preciseLocationDescriptor
.
NOTE:
The
user
agent
is
free
to
group
the
two
resulting
questions
for
the
user
into
a
single
GeolocationPermissionStatus
newGeolocationStatus
.
A
malicious
actor
could
potentially
infer
a
user's
precise
position
by
collecting
and
correlating
multiple,
distinct
approximate
positions
.
To
mitigate
this
risk
of
a
refinement
attack,
when
a
site
receives
an
approximate
position
,
or
any
subsequent
calls
from
that
same
site
within
a
user-agent-defined
time
window
SHOULD
return
the
relevant
browser
tab
is
closed.
exact
same,
cached
approximate
position
data.
A
user
agent
might,
for
example,
use
a
time
window
of
15
minutes.
There are no security considerations associated with Geolocation at the time of publication. However, readers are advised to read the 3. Privacy considerations .
WebIDL[Exposed=Window]
interface Geolocation {
undefined getCurrentPosition (
PositionCallback successCallback,
optional PositionErrorCallback? errorCallback = null,
optional = {}
optional PositionOptions options = {}
);
long watchPosition (
PositionCallback successCallback,
optional PositionErrorCallback? errorCallback = null,
optional = {}
optional PositionOptions options = {}
);
undefined clearWatch (long watchId);
};
callback PositionCallback = undefined (
GeolocationPosition position
);
callback PositionErrorCallback = undefined (
GeolocationPositionError positionError
);
Instances
of
Geolocation
are
created
with
the
internal
slots
in
the
following
table:
| Internal slot | Description |
|---|---|
| [[cachedPosition]] |
A
GeolocationPosition
,
initialized
to
null.
It's
a
reference
to
the
last
acquired
position
and
serves
as
a
cache.
A
user
agent
MAY
evict
[[cachedPosition]]
by
resetting
it
to
null
at
any
time
for
any
reason.
|
| [[watchIDs]] |
Initialized
as
an
empty
list
of
unsigned
long
items
.
|
The
getCurrentPosition
(
successCallback
,
errorCallback
,
options
)
method
steps
are:
Document
is
not
fully
active
:
POSITION_UNAVAILABLE
.
The
watchPosition
(
successCallback
,
errorCallback
,
options
)
method
steps
are:
Document
is
not
fully
active
:
POSITION_UNAVAILABLE
.
unsigned
long
that
is
greater
than
zero.
[[watchIDs]]
.
When
clearWatch()
is
invoked,
the
user
agent
MUST
:
[[watchIDs]]
.
To
request
a
position
,
pass
a
Geolocation
geolocation
,
a
PositionCallback
successCallback
,
a
PositionErrorCallback?
errorCallback
,
a
PositionOptions
options
,
and
an
optional
watchId
:
[[watchIDs]]
.
Document
.
"geolocation"
feature:
:
"geolocation-approximate"
:
PERMISSION_DENIED
.
accuracyMode
to
"
approximate
".
PERMISSION_DENIED
.
PermissionDescriptor
whose
name
is
"geolocation-approximate"
if
options
.
accuracyMode
is
"
approximate
",
otherwise
"geolocation"
.
null
.
"geolocation-approximate"
:
"geolocation"
):
PERMISSION_DENIED
.
To
acquire
a
position
,
passing
PositionCallback
successCallback
,
a
PositionErrorCallback?
errorCallback
,
PositionOptions
options
,
and
an
optional
watchId
.
[[watchIDs]]
does
not
contain
watchId
,
terminate
this
algorithm.
EpochTimeStamp
that
represents
now.
timeout
.
[[cachedPosition]]
.
PermissionDescriptor
with
its
name
set
to
"geolocation".
null
.
state
"geolocation"
accuracyMode
is
"approximate":
accuracyMode
is
"precise"):
accuracyMode
.
null
:
GeolocationPositionError
:
code
.
GeolocationPosition
passing
emulatedPositionData
,
acquisitionTime
enableHighAccuracy
report
".
maximumAge
is
greater
than
0:
maximumAge
member.
timestamp
's
value
is
greater
than
cacheTime
,
and
effectiveAccuracy
equals
cachedPosition
's
accuracyMode
,
and
cachedPosition
.
[[isHighAccuracy]]
equals
options
.
enableHighAccuracy
report
".
enableHighAccuracy
member
is
ignored.
enableHighAccuracy
double
that
represents
the
accuracy
value
indicating
the
95%
confidence
level
in
meters.
Accuracy
measures
how
close
the
measured
coordinates
are
to
the
true
position.
double?
that
represents
the
altitude
in
meters
above
the
[
WGS84
]
ellipsoid,
or
null
if
not
available.
Altitude
measures
the
height
above
sea
level.
double?
that
represents
the
altitude
accuracy,
or
null
if
not
available,
indicating
the
95%
confidence
level
in
meters.
Altitude
accuracy
measures
how
close
the
measured
altitude
is
to
the
true
altitude.
double?
that
represents
the
heading
in
degrees,
or
null
if
not
available
or
the
device
is
stationary.
Heading
measures
the
direction
in
which
the
device
is
moving
relative
to
true
north.
double
that
represents
the
latitude
coordinates
on
the
Earth's
surface
in
degrees,
using
the
[
WGS84
]
coordinate
system.
Latitude
measures
how
far
north
or
south
a
point
is
from
the
Equator.
double
that
represents
the
longitude
coordinates
on
the
Earth's
surface
in
degrees,
using
the
[
WGS84
]
coordinate
system.
Longitude
measures
how
far
east
or
west
a
point
is
from
the
Prime
Meridian.
double?
that
represents
the
speed
in
meters
per
second,
or
null
if
not
available.
Speed
measures
how
fast
the
device
is
moving.
GeolocationPosition
passing
positionData
,
acquisitionTime
enableHighAccuracy
[[cachedPosition]]
to
position
.
report
".
Call
back
with
error
passing
errorCallback
and
PERMISSION_DENIED
.
TIMEOUT
.
POSITION_UNAVAILABLE
.
When
instructed
to
call
back
with
error
,
given
an
PositionErrorCallback?
callback
and
an
unsigned
short
code
:
GeolocationPositionError
instance
whose
code
attribute
is
initialized
to
code
.
report
".
WebIDLenum AccuracyMode {
"precise",
"approximate"
};
dictionary PositionOptions {
AccuracyMode accuracyMode = "precise";
boolean enableHighAccuracy = false;
[Clamp] unsigned long timeout = 0xFFFFFFFF;
[Clamp] unsigned long maximumAge = 0;
};
The
accuracyMode
member
is
used
to
request
a
specific
level
of
accuracy.
It
can
be
set
to
"precise"
to
request
the
most
accurate
location
data
available,
or
"approximate"
to
receive
a
less
accurate
location
that
protects
user
privacy.
The
default
value
is
"precise".
The
enableHighAccuracy
member
provides
a
hint
that
the
application
would
like
to
receive
the
most
accurate
location
data.
The
intended
purpose
of
this
member
is
to
allow
applications
to
inform
the
implementation
that
they
do
not
require
high
accuracy
geolocation
fixes
and,
therefore,
the
implementation
MAY
avoid
using
geolocation
providers
that
consume
a
significant
amount
of
power
(e.g.,
GPS).
The
timeout
member
denotes
the
maximum
length
of
time,
expressed
in
milliseconds,
before
acquiring
a
position
expires.
The
time
spent
waiting
for
the
document
to
become
visible
and
for
obtaining
permission
to
use
the
API
is
not
included
in
the
period
covered
by
the
timeout
member.
The
timeout
member
only
applies
when
acquiring
a
position
begins.
The
maximumAge
member
indicates
that
the
web
application
is
willing
to
accept
a
cached
position
whose
age
is
no
greater
than
the
specified
time
in
milliseconds.
WebIDL[Exposed=Window, SecureContext]
interface GeolocationPosition {
readonly attribute GeolocationCoordinates coords;
readonly attribute
readonly attribute EpochTimeStamp timestamp;
readonly attribute AccuracyMode accuracyMode;
[Default] object toJSON();
};
The
coords
attribute
contains
geographic
coordinates.
The
timestamp
attribute
represents
the
time
when
the
geographic
position
of
the
device
was
acquired.
The
toJSON()
accuracyMode
method
attribute
indicates
the
accuracy
level
of
the
position,
which
can
be
either
"precise"
or
"approximate"
.
This
reflects
the
level
of
accuracy
that
was
granted
and
used
to
allow
obtain
the
position.
GeolocationPosition
toJSON()
method
The
toJSON()
method
returns
a
JSON
representation
of
the
GeolocationPosition
object.
Instances
of
GeolocationPosition
are
created
with
the
internal
slots
in
the
following
table:
| Internal slot | Description |
|---|---|
| [[isHighAccuracy]] |
A
boolean
that
records
the
value
of
the
enableHighAccuracy
member
when
this
GeolocationPosition
is
created
.
|
The following task source is defined by this specification.
PositionCallback
and
PositionErrorCallback
when
performing
position
requests
.
WebIDL[Exposed=Window, SecureContext]
interface GeolocationCoordinates {
readonly attribute double accuracy;
readonly attribute double latitude;
readonly attribute double longitude;
readonly attribute double? altitude;
readonly attribute double? altitudeAccuracy;
readonly attribute double? heading;
readonly attribute double? speed;
[Default] object toJSON();
};
The
latitude
and
longitude
attributes
are
geographic
coordinates
specified
in
decimal
degrees.
The
latitude
and
longitude
attributes
denote
the
position,
specified
as
a
real
number
of
degrees,
in
the
[
WGS84
]
coordinate
system.
The
accuracy
attribute
denotes
the
accuracy
level
of
the
latitude
and
longitude
coordinates
in
meters
(e.g.,
65
meters).
The
accuracy
attribute
denotes
the
position
accuracy
radius
in
meters.
The
altitude
attribute
denotes
the
height
of
the
position,
specified
in
meters
above
the
[
WGS84
]
ellipsoid.
The
altitudeAccuracy
attribute
represents
the
altitude
accuracy
in
meters
(e.g.,
10
meters).
The
heading
attribute
denotes
the
direction
of
travel
of
the
hosting
device
and
is
specified
in
degrees,
where
0°
≤
heading
<
360°,
counting
clockwise
relative
to
the
true
north.
The
speed
attribute
denotes
the
magnitude
of
the
horizontal
component
of
the
hosting
device's
current
velocity
in
meters
per
second.
The
toJSON()
method
returns
a
JSON
representation
of
the
GeolocationCoordinates
object.
GeolocationPosition
is
constructed
with
map
positionData
,
EpochTimeStamp
timestamp
GeolocationCoordinates
instance.
GeolocationPosition
instance
with
its
coords
attribute
initialized
to
coords
timestamp
attribute
initialized
to
timestamp
,
[[isHighAccuracy]]
internal
slot
set
to
isHighAccuracy
timestamp
accuracyMode
attribute
initialized
to
WebIDL[Exposed=Window]
interface GeolocationPositionError {
const unsigned short PERMISSION_DENIED = 1;
const unsigned short TIMEOUT = 3;
readonly attribute unsigned short code;
readonly attribute DOMString message;
};
PERMISSION_DENIED
(numeric
value
1)
POSITION_UNAVAILABLE
(numeric
value
2)
TIMEOUT
(numeric
value
3)
timeout
member
has
elapsed
before
the
user
agent
could
successfully
acquire
a
position
.
The
code
attribute
returns
the
value
it
was
initialized
to
(see
10.1
Constants
for
possible
values).
The
message
attribute
is
a
developer-friendly
textual
description
of
the
code
attribute.
"geolocation"
and
"geolocation-approximate"
.
The "geolocation" policy controls access to precise position , while "geolocation-approximate" controls access to approximate position . Granting "geolocation" permission implicitly grants "geolocation-approximate" permission as well, while restricting "geolocation-approximate" also restricts "geolocation".
For the purposes of user-agent automation and application testing, this document defines geolocation emulations.
Each
top-level
traversable
has
an
associated
emulated
position
data
,
which
is
data
representing
GeolocationCoordinates
,
GeolocationPositionError
or
null,
initially
null.
To set emulated position data , given navigable navigable and an emulatedPositionData :
GeolocationCoordinates
,
or
a
GeolocationPositionError
.
To
get
emulated
position
data
,
given
Geolocation
geolocation
:
Document
's
node
navigable
.
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The
key
words
MAY
,
MUST
,
RECOMMENDED
,
and
SHOULD
in
this
document
are
to
be
interpreted
as
described
in
BCP
14
[
RFC2119
]
[
RFC8174
]
when,
and
only
when,
they
appear
in
all
capitals,
as
shown
here.
WebIDLpartial interface Navigator {
[SameObject] readonly attribute Geolocation geolocation;
};
]
[Exposed=Window]
interface Geolocation {
undefined getCurrentPosition (
PositionCallback successCallback,
optional PositionErrorCallback? errorCallback = null,
optional = {}
optional PositionOptions options = {}
);
long watchPosition (
PositionCallback successCallback,
optional PositionErrorCallback? errorCallback = null,
optional = {}
optional PositionOptions options = {}
);
undefined clearWatch (long watchId);
};
callback PositionCallback = undefined (
GeolocationPosition position
);
callback PositionErrorCallback = undefined (
GeolocationPositionError positionError
);
enum AccuracyMode {
"precise",
"approximate"
};
dictionary PositionOptions {
AccuracyMode accuracyMode = "precise";
boolean enableHighAccuracy = false;
[Clamp] unsigned long timeout = 0xFFFFFFFF;
[Clamp] unsigned long maximumAge = 0;
};
]
[Exposed=Window, SecureContext]
interface GeolocationPosition {
readonly attribute
readonly attribute
readonly attribute GeolocationCoordinates coords;
readonly attribute EpochTimeStamp timestamp;
readonly attribute AccuracyMode accuracyMode;
[Default] object toJSON();
};
]
interface
readonly attribute
readonly attribute
readonly attribute
readonly attribute
readonly attribute
readonly attribute
readonly attribute
[Exposed=Window, SecureContext]
interface GeolocationCoordinates {
readonly attribute double accuracy;
readonly attribute double latitude;
readonly attribute double longitude;
readonly attribute double? altitude;
readonly attribute double? altitudeAccuracy;
readonly attribute double? heading;
readonly attribute double? speed;
[Default] object toJSON();
};
]
[Exposed=Window]
interface GeolocationPositionError {
const unsigned short PERMISSION_DENIED = 1;
const unsigned short POSITION_UNAVAILABLE = 2;
const unsigned short TIMEOUT = 3;
readonly attribute unsigned short code;
readonly attribute DOMString message;
};
accuracy
attribute
for
GeolocationCoordinates
§9.1
AccuracyMode
enum
§7.
altitude
attribute
for
GeolocationCoordinates
§9.2
altitudeAccuracy
attribute
for
GeolocationCoordinates
§9.2
"approximate"
enum
value
for
AccuracyMode
§7.
[[cachedPosition]]
internal
slot
for
Geolocation
§6.1
clearWatch()
method
for
Geolocation
§6.4
code
attribute
for
GeolocationPositionError
§10.2
coords
attribute
for
GeolocationPosition
§8.1
enableHighAccuracy
member
for
PositionOptions
geolocation
attribute
for
Navigator
§5.1
Geolocation
interface
§6.
"geolocation-approximate"
§3.4
"geolocation"
§3.4
GeolocationCoordinates
interface
§9.
GeolocationPermissionStatus
interface
§3.4
GeolocationPosition
interface
§8.
GeolocationPositionError
interface
§10.
getCurrentPosition
method
for
Geolocation
§6.2
heading
attribute
for
GeolocationCoordinates
§9.3
[[isHighAccuracy]]
internal
slot
for
GeolocationPosition
latitude
attribute
for
GeolocationCoordinates
§9.1
longitude
attribute
for
GeolocationCoordinates
§9.1
maximumAge
member
for
PositionOptions
message
attribute
for
GeolocationPositionError
§10.3
PERMISSION_DENIED
§10.1
POSITION_UNAVAILABLE
§10.1
PositionCallback
§6.
PositionErrorCallback
§6.
PositionOptions
dictionary
§7.
"precise"
enum
value
for
AccuracyMode
§7.
speed
attribute
for
GeolocationCoordinates
§9.4
timeout
member
for
PositionOptions
TIMEOUT
§10.1
timestamp
attribute
for
GeolocationPosition
§8.2
GeolocationPosition
GeolocationCoordinates
§9.5
[[watchIDs]]
internal
slot
for
Geolocation
§6.1
watchPosition
method
for
Geolocation
§6.3
EpochTimeStamp
allow
attribute
(for
iframe
element)
Document
)
iframe
element
Document
)
list
)
list
)
map
)
list
)
list
)
permission
)
permission
)
permission
)
name
(for
PermissionDescriptor
)
PermissionDescriptor
PermissionStatus
interface
state
attribute
(for
PermissionStatus
)
boolean
type
[Clamp]
extended
attribute
[Default]
extended
attribute
DOMString
interface
double
type
[Exposed]
extended
attribute
long
type
object
type
[SameObject]
extended
attribute
[SecureContext]
extended
attribute
undefined
type
unsigned
long
type
unsigned
short
type
This section is non-normative.
This specification builds upon earlier work in the industry, including research by Aza Raskin, Google Gears Geolocation API, and LocationAware.org.
Thanks also to Alec Berntson, Alissa Cooper, Steve Block, Greg Bolsinga, Lars Erik Bolstad, Aaron Boodman, Dave Burke, Chris Butler, Max Froumentin, Shyam Habarakada, Marcin Hanclik, Ian Hickson, Brad Lassey, Angel Machin, Cameron McCormack, Daniel Park, Stuart Parmenter, Olli Pettay, Chris Prince, Arun Ranganathan, Carl Reed, Thomas Roessler, Dirk Segers, Allan Thomson, Martin Thomson, Doug Turner, Erik Wilde, Matt Womer, and Mohamed Zergaoui.
This section is non-normative.
Since publication as a W3C Recommendation in 2022, Geolocation has received the following normative changes:
Since First Public Working Draft in 2021, until it was published as a W3C Recommendation in 2022, Geolocation received the following normative changes:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Since publication of the Second Edition in 2016, this specification received the following substantive changes:
errorCallback
is
now
nullable.
callbacks
are
no
longer
treated
as
"EventHandler"
objects
(i.e.,
objects
that
have
a
.handleEvent()
method),
but
are
now
exclusively
treated
as
IDL
callback
functions.
[NoInterfaceObject]
,
so
Geolocation
and
other
interface
of
this
spec
are
now
in
the
global
scope.
Also,
the
interfaces
were
renamed
from
NavigatorGeolocation*
to
just
Geolocation*
.
See the commit history for a complete list of changes.