├── .pr-preview.json ├── tidyconfig.txt ├── w3c.json ├── CODE_OF_CONDUCT.md ├── spec-source.html ├── .github ├── workflows │ ├── tidy.yml │ ├── auto-publish.yml │ └── auto-publish-errata.yml └── PULL_REQUEST_TEMPLATE.md ├── CONTRIBUTING.md ├── errata.html ├── README.md ├── reports └── implementation.html └── index.html /.pr-preview.json: -------------------------------------------------------------------------------- 1 | { 2 | "src_file": "index.html", 3 | "type": "respec" 4 | } 5 | -------------------------------------------------------------------------------- /tidyconfig.txt: -------------------------------------------------------------------------------- 1 | char-encoding: utf8 2 | indent: yes 3 | wrap: 80 4 | tidy-mark: no 5 | newline: LF 6 | custom-tags: yes 7 | -------------------------------------------------------------------------------- /w3c.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "group": 43696, 4 | "contacts": [ 5 | "himorin" 6 | ], 7 | "policy": "open", 8 | "repo-type": "rec-track" 9 | } 10 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | All documentation, code and communication under this repository are covered by the [W3C Code of Ethics and Professional Conduct](https://www.w3.org/Consortium/cepc/). 4 | -------------------------------------------------------------------------------- /spec-source.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 |This document got moved to index.html
8 | 9 | 10 | -------------------------------------------------------------------------------- /.github/workflows/tidy.yml: -------------------------------------------------------------------------------- 1 | name: Tidy document 2 | on: 3 | workflow_dispatch: {} 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - index.html 9 | 10 | jobs: 11 | tidy: 12 | name: Tidy up 13 | runs-on: macos-latest 14 | steps: 15 | - uses: actions/checkout@v4 16 | - run: brew install tidy-html5 17 | - run: tidy -config tidyconfig.txt -o index.html index.html 18 | - uses: peter-evans/create-pull-request@v6 19 | with: 20 | title: "Tidied up document using tidy-html5" 21 | commit-message: "chore(tidy): tidy up document" 22 | branch: html-tidy 23 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Closes #??? 2 | 3 | The following tasks have been completed: 4 | 5 | * [ ] Modified Web platform tests (link to pull request) 6 | 7 | Implementation commitment (and no objections): 8 | 9 | * [ ] WebKit (https://bugs.webkit.org/show_bug.cgi?id=) 10 | * [ ] Chromium (https://bugs.chromium.org/p/chromium/issues/detail?id=) 11 | * [ ] Gecko (https://bugzilla.mozilla.org/show_bug.cgi?id=) 12 | 13 | Documentation (new feature): 14 | 15 | * [ ] Updated implementation report 16 | * [ ] Pinged MDN 17 | * [ ] Added example to README or spec 18 | 19 | For documentation, either create an [issue](https://github.com/mdn/content/issues) or pull request in [MDN's Content](https://github.com/mdn/content) repo - providing as much information as you can. PR is prefered. 20 | -------------------------------------------------------------------------------- /.github/workflows/auto-publish.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - index.html 9 | - errata.html 10 | pull_request: {} 11 | 12 | jobs: 13 | validate-and-publish: 14 | name: Validate and Publish 15 | runs-on: ubuntu-latest # only linux supported at present 16 | steps: 17 | - uses: actions/checkout@v2 18 | - uses: w3c/spec-prod@v2 19 | with: 20 | TOOLCHAIN: respec 21 | VALIDATE_LINKS: false 22 | VALIDATE_PUBRULES: false 23 | GH_PAGES_BRANCH: gh-pages 24 | W3C_ECHIDNA_TOKEN: ${{ secrets.ECHIDNA_TOKEN }} 25 | W3C_WG_DECISION_URL: "https://lists.w3.org/Archives/Public/public-device-apis/2021May/0008.html" 26 | W3C_NOTIFICATIONS_CC: "${{ secrets.CC }}" 27 | W3C_BUILD_OVERRIDE: | 28 | specStatus: REC 29 | -------------------------------------------------------------------------------- /.github/workflows/auto-publish-errata.yml: -------------------------------------------------------------------------------- 1 | name: Node CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | paths: 8 | - errata.html 9 | - reports/implementation.html 10 | pull_request: {} 11 | 12 | jobs: 13 | generate-errata: 14 | name: Generate errata and implementation report 15 | runs-on: ubuntu-latest # only linux supported at present 16 | permissions: 17 | contents: write 18 | strategy: 19 | max-parallel: 1 20 | matrix: 21 | include: 22 | - source: errata.html 23 | - source: reports/implementation.html 24 | steps: 25 | - uses: actions/checkout@v4 26 | - uses: w3c/spec-prod@v2 27 | with: 28 | SOURCE: ${{ matrix.source }} 29 | TOOLCHAIN: respec 30 | VALIDATE_LINKS: false 31 | VALIDATE_PUBRULES: false 32 | GH_PAGES_BRANCH: gh-pages 33 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Spec development happens via [issues in this repository](https://github.com/w3c/geolocation/issues) and [pull requests](https://github.com/w3c/geolocation/pulls). 2 | 3 | For normative changes, a corresponding [web-platform-tests](https://github.com/web-platform-tests/wpt) PR is highly appreciated. Typically, both PRs will be merged at the same time. If testing is not practical, please explain why and if appropriate [file an issue](https://github.com/web-platform-tests/wpt/issues/new) to follow up later. 4 | 5 | Contributions to this repository are intended to become part of Recommendation-track documents 6 | governed by the [W3C Patent Policy](http://www.w3.org/Consortium/Patent-Policy-20040205/) and 7 | [Software and Document License](http://www.w3.org/Consortium/Legal/copyright-software). To contribute, you must 8 | either participate in the relevant W3C Working Group or make a non-member patent licensing 9 | commitment. 10 | 11 | If you are not the sole contributor to a contribution (pull request), please identify all 12 | contributors in the pull request's body or in subsequent comments. 13 | 14 | To add a contributor (other than yourself, that's automatic), mark them one per line as follows: 15 | 16 | ``` 17 | +@github_username 18 | ``` 19 | 20 | If you added a contributor by mistake, you can remove them in a comment with: 21 | 22 | ``` 23 | -@github_username 24 | ``` 25 | 26 | If you are making a pull request on behalf of someone else but you had no part in designing the 27 | feature, you can remove yourself with the above syntax. 28 | 29 | To build a local copy of the specification, please refer to [respec documentation](https://respec.org/docs/#using-command-line). 30 | -------------------------------------------------------------------------------- /errata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |This is an implementation report for [[Geolocation]].
40 |43 | As Geolocation requires explicit permission grant to be used (via a 44 | browser UI), the following assertions were tested manually to assure 45 | interoperability across browser engines. 46 |
47 |48 | As some of the tests rely on the [[Permissions]] specifications automation 49 | API, which is only partially supported in Chrome, some the test were 50 | modified locally to get them to pass across browser engines. However, the 51 | working group expects that eventually all browser engines will support the 52 | [[Permissions]]'s automation API and wpt.fyi will reflect 53 | 56 | accurate results 58 | for [[Geolocation]]. 59 |
60 || Test | 63 |Chromium | 64 |Gecko | 65 |WebKit | 66 |
|---|---|---|---|
| 69 | PositionOptions.https.html 72 | | 73 |UNTESTED | 74 |UNTESTED | 75 |UNTESTED | 76 |
| 79 | clearWatch_TypeError.https.html 82 | | 83 |PASS | 84 |PASS | 85 |PASS | 86 |
| 89 | disabled-by-permissions-policy.https.sub.html 93 | | 94 |UNTESTED | 95 |UNTESTED | 96 |UNTESTED | 97 |
| 100 | enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html 104 | | 105 |UNTESTED | 106 |UNTESTED | 107 |UNTESTED | 108 |
| 111 | enabled-by-permission-policy-attribute.https.sub.html 115 | | 116 |UNTESTED | 117 |UNTESTED | 118 |UNTESTED | 119 |
| 122 | enabled-by-permissions-policy.https.sub.html 126 | | 127 |UNTESTED | 128 |UNTESTED | 129 |UNTESTED | 130 |
| 133 | enabled-on-self-origin-by-permissions-policy.https.sub.html 137 | | 138 |UNTESTED | 139 |UNTESTED | 140 |UNTESTED | 141 |
| 144 | getCurrentPosition_TypeError.https.html 148 | | 149 |PASS | 150 |PASS | 151 |PASS | 152 |
| 155 | getCurrentPosition_permission_allow.https.html 159 | | 160 |UNTESTED | 161 |UNTESTED | 162 |UNTESTED | 163 |
| 166 | getCurrentPosition_permission_deny.https.html 170 | | 171 |UNTESTED | 172 |UNTESTED | 173 |UNTESTED | 174 |
| 177 | idlharness.https.window.js 180 | | 181 |UNTESTED | 182 |UNTESTED | 183 |UNTESTED | 184 |
| 187 | non-fully-active.https.html 190 | | 191 |FAIL | 192 |PASS | 193 |FAIL | 194 |
| 197 | non-secure-contexts.http.html 200 | | 201 |PASS | 202 |PASS | 203 |PASS | 204 |
| 207 | permission.https.html 210 | | 211 |PASS | 212 |PASS | 213 |PASS | 214 |
| 217 | watchPosition_TypeError.https.html 221 | | 222 |PASS | 223 |PASS | 224 |PASS | 225 |
| 228 | watchPosition_permission_deny.https.html 232 | | 233 |PASS | 234 |PASS | 235 |PASS | 236 |
243 | The current specification features are implemented across major browsers 244 | like Chrome, Firefox, and Safari. This is demonstrated through the 245 | aforementioned web platform tests (WPT), which verify the implementation 246 | of the specification's features, such as obtaining the location, handling 247 | permissions, and responding to errors. 248 |
249 |254 | Yes, there are independent interoperable implementations of the Major web 255 | browsers such as Chrome, Firefox, and Safari provide their own 256 | implementations, which have been tested to ensure they conform to the 257 | W3C's specifications and work interoperability across different platforms 258 | and operating systems. 259 |
260 |265 | Yes, implementations of Geolocation have been created by various browser 266 | vendors who are not necessarily the editors of the specification. This 267 | includes engineers from Google, Mozilla, Microsoft, and Apple, among 268 | others, ensuring a broad base of experience and design input is reflected 269 | in the API. 270 |
271 |273 | Yes, the implementations of Geolocation are publicly deployed and widely 274 | used in web applications. These are accessible in consumer-level browsers, 275 | allowing developers to incorporate geolocation features into their 276 | websites and applications, enhancing user experience with location-based 277 | services. 278 |
279 |284 | There is substantial implementation experience at all levels of the 285 | specification's ecosystem. Developers use the API to author location-based 286 | services, consumers use these features in daily web interactions, and 287 | publishers integrate these capabilities into various applications for 288 | enhanced contextual experiences. 289 |
290 |292 | While the core functionality of Geolocation is well-supported, developers 293 | occasionally report difficulties related to privacy concerns, varying 294 | accuracy levels, and handling user permissions across different browsers 295 | and devices. These issues are typically addressed through updates to the 296 | specification and improvements in browser implementations. 297 |
298 | 299 | 300 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |55 | Geolocation provides access to geographical location information 56 | associated with the hosting device. 57 |
58 |68 | Since this specification became a W3C Recommendation on 01 September 69 | 2022, the following substantive additions and/or corrections have been 70 | proposed: 71 |
74 | A more detailed list of changes can be found in section 75 | [[[#changelog]]]. Reviewers of the document can identify candidate 76 | additions and/or corrections by their distinctive styling in the 77 | document. 78 |
79 |85 | Geolocation defines a high-level interface to location 86 | information associated only with the device hosting the implementation. 87 | Common sources of location information include Global Positioning 88 | System (GPS) and location inferred from network signals such as IP 89 | address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, 90 | as well as user input. The API itself is agnostic of the underlying 91 | location information sources, and no guarantee is given that the API 92 | returns the device's actual location. 93 |
94 |95 | If an end user [=check permission|grants permission=], 96 | Geolocation: 97 |
98 |127 | This specification is limited to providing a scripting API for 128 | retrieving geographic position information associated with a hosting 129 | device. The geographic position information is provided in terms of 130 | World Geodetic System coordinates [[WGS84]]. It does not include 131 | providing a markup language of any kind, nor does it include defining 132 | a new URL scheme for building URLs that identify geographic 133 | locations. 134 |
135 |142 | The API is designed to enable both "one-shot" position requests and 143 | repeated position updates. The following examples illustrate common use 144 | cases. 145 |
146 |151 | Request the user's current location. If the user allows it, you will 152 | get back a position object. 153 |
154 | 162 |168 | Request the ability to watch user's current location. If the user 169 | allows it, you will get back continuous updates of the user's 170 | position. 171 |
172 | 181 |187 | Stop watching for position changes by calling the 188 | {{Geolocation/clearWatch()}} method. 189 |
190 | 210 |216 | When an error occurs, the second argument of the 217 | {{Geolocation/watchPosition()}} or 218 | {{Geolocation/getCurrentPosition()}} method gets called with a 219 | {{GeolocationPositionError}} error, which can help you figure out 220 | what might have gone wrong. 221 |
222 | 251 |257 | By default, the API always attempts to return a cached position so 258 | long as it has a previously acquired position. In this example, we 259 | accept a position whose age is no greater than 10 minutes. If the 260 | user agent does not have a fresh enough cached position object, it 261 | automatically acquires a new position. 262 |
263 | 277 |283 | If you require location information in a time sensitive manner, you 284 | can use the {{PositionOptions}} {{PositionOptions/timeout}} member to 285 | limit the amount of time you are willing to wait to [=acquire a 286 | position=]. 287 |
288 | 320 |326 | The [=policy-controlled feature/default allowlist=] of `'self'` 327 | allows API usage in same-origin nested frames but prevents 328 | third-party content from using the API. 329 |
330 |331 | Third-party usage can be selectively enabled by adding the 332 | [^iframe/allow^]`="geolocation"` attribute to an [^iframe^] element: 333 |
334 | 342 |343 | Alternatively, the API can be disabled in a first-party context by 344 | specifying an HTTP response header: 345 |
346 | 351 |352 | See [[[permissions-policy]]] for more details about the 353 | `Permissions-Policy` HTTP header. 354 |
355 |362 | The API defined in this specification is used to retrieve the 363 | geographic location of a hosting device. In almost all cases, this 364 | information also discloses the location of the user of the device, 365 | thereby potentially compromising the user's privacy. 366 |
367 |372 | Geolocation is a [=powerful feature=] that requires 373 | [=express permission=] from an end-user before any location data is 374 | shared with a web application. This requirement is normatively 375 | enforced by the [=check permission=] steps on which the 376 | {{Geolocation/getCurrentPosition()}} and 377 | {{Geolocation/watchPosition()}} methods rely. 378 |
379 |380 | An end-user will generally give [=express permission=] through a user 381 | interface, which usually presents a range of permission 382 | [=permission/lifetimes=] that the end-user can choose from. The 383 | choice of [=permission/lifetimes=] vary across user agents, but they 384 | are typically time-based (e.g., "a day"), or until browser is closed, 385 | or the user might even be given the choice for the permission to be 386 | granted indefinitely. The permission [=permission/lifetimes=] dictate 387 | how long a user agent [=permission/granted|grants=] a permission 388 | before that permission is automatically reverted back to its default 389 | [=permission state=], prompting the end-user to make a new choice 390 | upon subsequent use. 391 |
392 |393 | Although the granularity of the permission [=permission/lifetime=] 394 | varies across user-agents, this specification urges user agents to 395 | limit the lifetime to a single browsing session by default (see 396 | [[[#check-permission]]] for normative requirements). 397 |
398 |405 | This section applies to "recipients", which generally means 406 | developers utilizing Geolocation. Although it's 407 | impossible for the user agent, or this specification, to enforce 408 | these requirements, developers need to read this section carefully 409 | and do their best to adhere to the suggestions below. Developers need 410 | to be aware that there might be privacy laws in their jurisdictions 411 | that can govern the usage and access to users' location data. 412 |
413 |414 | Recipients ought to only request position information when necessary, 415 | and only use the location information for the task for which it was 416 | provided to them. Recipients ought to dispose of location information 417 | once that task is completed, unless expressly permitted to retain it 418 | by the user. Recipients need to also take measures to protect this 419 | information against unauthorized access. If location information is 420 | stored, users need to be allowed to update and delete this 421 | information. 422 |
423 |424 | The recipients of location information need to refrain from 425 | retransmitting the location information without the user’s express 426 | permission. Care needs to be taken when retransmitting and the use of 427 | encryption is encouraged. 428 |
429 |430 | Recipients ought to clearly and conspicuously disclose the fact that 431 | they are collecting location data, the purpose for the collection, 432 | how long the data is retained, how the data is secured, how the data 433 | is shared if it is shared, how users can access, update and delete 434 | the data, and any other choices that users have with respect to the 435 | data. This disclosure needs to include an explanation of any 436 | exceptions to the guidelines listed above. 437 |
438 |444 | Implementers are advised to consider the following aspects that can 445 | negatively affect the privacy of their users: in certain cases, users 446 | can inadvertently grant permission to the user agent to disclose 447 | their location to websites. In other cases, the content hosted at a 448 | certain URL changes in such a way that the previously granted 449 | location permissions no longer apply as far as the user is concerned. 450 | Or the users might simply change their minds. 451 |
452 |453 | Predicting or preventing these situations is inherently difficult. 454 | Mitigation and in-depth defensive measures are an implementation 455 | responsibility and not prescribed by this specification. However, in 456 | designing these measures, implementers are advised to enable user 457 | awareness of location sharing, and to provide access to user 458 | interfaces that enable revocation of permissions. 459 |
460 |
466 | Geolocation is a [=default powerful feature=] identified
467 | by the [=powerful feature/name=] "geolocation".
469 |
471 | When checking permission 472 | to use the API, a user agent MAY suggest time-based [=permission=] 473 | [=permission/lifetimes=], such as "24 hours", "1 week", or choose to 474 | remember the permission [=permission/grant=] indefinitely. However, 475 | it is RECOMMENDED that a user agent prioritize restricting the 476 | [=permission=] [=permission/lifetime=] to a single session: This can 477 | be, for example, until the [=environment settings object/realm=] is 478 | destroyed, the end-user [=navigates=] away from the [=origin=], or 479 | the relevant browser tab is closed. 480 |
481 |488 | There are no security considerations associated with Geolocation at the 489 | time of publication. However, readers are advised to read the 490 | [[[#privacy]]]. 491 |
492 |
515 | [Exposed=Window]
516 | interface Geolocation {
517 | undefined getCurrentPosition (
518 | PositionCallback successCallback,
519 | optional PositionErrorCallback? errorCallback = null,
520 | optional PositionOptions options = {}
521 | );
522 |
523 | long watchPosition (
524 | PositionCallback successCallback,
525 | optional PositionErrorCallback? errorCallback = null,
526 | optional PositionOptions options = {}
527 | );
528 |
529 | undefined clearWatch (long watchId);
530 | };
531 |
532 | callback PositionCallback = undefined (
533 | GeolocationPosition position
534 | );
535 |
536 | callback PositionErrorCallback = undefined (
537 | GeolocationPositionError positionError
538 | );
539 |
540 | 545 | Instances of {{Geolocation}} are created with the internal slots in 546 | the following table: 547 |
548 || 551 | Internal slot 552 | | 553 |554 | Description 555 | | 556 |
|---|---|
| 559 | [[\cachedPosition]] 560 | | 561 |562 | A {{GeolocationPosition}}, initialized to null. It's a reference 563 | to the last acquired position and serves as a cache. A user agent 564 | MAY evict {{Geolocation/[[cachedPosition]]}} by resetting it to 565 | null at any time for any reason. 566 | | 567 |
| 570 | [[\watchIDs]] 571 | | 572 |573 | Initialized as an empty [=list=] of {{unsigned long}} 574 | [=list/item|items=]. 575 | | 576 |
585 | The getCurrentPosition(|successCallback:PositionCallback|, 586 | |errorCallback:PositionErrorCallback?|, |options:PositionOptions|) 587 | method steps are: 588 |
589 |619 | The watchPosition(|successCallback:PositionCallback|, 620 | |errorCallback:PositionErrorCallback?|, |options:PositionOptions|) 621 | method steps are: 622 |
623 |660 | When clearWatch() is invoked, the user agent MUST: 661 |
662 |673 | To request a position, pass a {{Geolocation}} 674 | |geolocation:Geolocation|, a {{PositionCallback}} 675 | |successCallback:PositionCallback|, a {{PositionErrorCallback?}} 676 | |errorCallback:PositionErrorCallback?|, a {{PositionOptions}} 677 | |options:PositionOptions|, and an optional |watchId:unsigned long|: 678 |
679 | 683 | 690 |805 | To acquire a position, 807 | passing {{PositionCallback}} |successCallback:PositionCallback|, a 808 | {{PositionErrorCallback?}} |errorCallback:PositionErrorCallback?|, 809 | {{PositionOptions}} |options:PositionOptions|, and an optional 810 | |watchId:unsigned long|. 811 |
812 |1056 | [=Call back with error=] passing |errorCallback| and 1057 | {{GeolocationPositionError/PERMISSION_DENIED}}. 1058 |
1059 | 1069 |1097 | When instructed to call back with error, given an 1098 | {{PositionErrorCallback?}} |callback:PositionErrorCallback?| and an 1099 | {{unsigned short}} |code:unsigned short|: 1100 |
1101 |
1119 | dictionary PositionOptions {
1120 | boolean enableHighAccuracy = false;
1121 | [Clamp] unsigned long timeout = 0xFFFFFFFF;
1122 | [Clamp] unsigned long maximumAge = 0;
1123 | };
1124 |
1125 | 1130 | The enableHighAccuracy member provides a hint that the 1131 | application would like to receive the most accurate location data. 1132 | The intended purpose of this member is to allow applications to 1133 | inform the implementation that they do not require high accuracy 1134 | geolocation fixes and, therefore, the implementation MAY avoid using 1135 | geolocation providers that consume a significant amount of power 1136 | (e.g., GPS). 1137 |
1138 | 1146 |1152 | The timeout member denotes the maximum length of time, 1153 | expressed in milliseconds, before [=acquiring a position=] expires. 1154 |
1155 |1156 | The time spent waiting for the document to become visible and for 1157 | [=check permission|obtaining permission to use the API=] is not 1158 | included in the period covered by the {{PositionOptions/timeout}} 1159 | member. The {{PositionOptions/timeout}} member only applies when 1160 | [=acquiring a position=] begins. 1161 |
1162 | 1168 |1174 | The maximumAge member indicates that the web application 1175 | is willing to accept a cached position whose age is no greater than 1176 | the specified time in milliseconds. 1177 |
1178 |
1185 | [Exposed=Window, SecureContext]
1186 | interface GeolocationPosition {
1187 | readonly attribute GeolocationCoordinates coords;
1188 | readonly attribute EpochTimeStamp timestamp;
1189 | [Default] object toJSON();
1190 | };
1191 |
1192 | 1197 | The coords attribute contains geographic coordinates. 1198 |
1199 |1205 | The timestamp attribute represents the time when the 1206 | geographic position of the device was acquired. 1207 |
1208 |1220 | The toJSON() method returns a JSON 1221 | representation of the {{GeolocationPosition}} object. 1222 |
1223 |1229 | Instances of {{GeolocationPosition}} are created with the internal 1230 | slots in the following table: 1231 |
1232 || 1235 | Internal slot 1236 | | 1237 |1238 | Description 1239 | | 1240 |
|---|---|
| 1243 | [[\isHighAccuracy]] 1244 | | 1245 |1246 | A {{boolean}} that records the value of the 1247 | {{PositionOptions/enableHighAccuracy}} member when this 1248 | {{GeolocationPosition}} is [=a new GeolocationPosition|created=]. 1249 | | 1250 |
1258 | The following [=task source=] is defined by this specification. 1259 |
1260 |
1277 | [Exposed=Window, SecureContext]
1278 | interface GeolocationCoordinates {
1279 | readonly attribute double accuracy;
1280 | readonly attribute double latitude;
1281 | readonly attribute double longitude;
1282 | readonly attribute double? altitude;
1283 | readonly attribute double? altitudeAccuracy;
1284 | readonly attribute double? heading;
1285 | readonly attribute double? speed;
1286 | [Default] object toJSON();
1287 | };
1288 |
1289 |
1306 | The latitude and
1307 | longitude attributes are geographic coordinates
1308 | specified in decimal degrees. The
1309 | latitude and longitude attributes denote the
1310 | position, specified as a real number of degrees, in the [[WGS84]]
1311 | coordinate system.
1312 |
1314 | The accuracy attribute denotes the
1315 | accuracy level of the latitude and longitude coordinates in meters
1316 | (e.g., `65` meters). The accuracy
1317 | attribute denotes the position accuracy radius in meters.
1318 |
1325 | The altitude attribute denotes the height of the position, 1326 | specified in meters above the [[WGS84]] ellipsoid. 1327 |
1328 |1329 | The altitudeAccuracy attribute represents the altitude 1330 | accuracy in meters (e.g., `10` meters). 1331 |
1332 |1338 | The heading attribute denotes the direction of travel of 1339 | the hosting device and is specified in degrees, where 0° ≤ heading 1340 | < 360°, counting clockwise relative to the true north. 1341 |
1342 |1348 | The speed attribute denotes the magnitude of the 1349 | horizontal component of the hosting device's current velocity in 1350 | meters per second. 1351 |
1352 |1364 | The toJSON() method returns a JSON 1365 | representation of the {{GeolocationCoordinates}} object. 1366 |
1367 |1379 | A new `GeolocationPosition` is constructed with [=map=] 1380 | |positionData|, {{EpochTimeStamp}} |timestamp:EpochTimeStamp| and 1381 | boolean |isHighAccuracy| by performing the following steps: 1382 |
1383 |1401 | A new `GeolocationPosition` is constructed with 1402 | {{EpochTimeStamp}} |timestamp:EpochTimeStamp| and boolean 1403 | |isHighAccuracy| by performing the following steps: 1404 |
1405 |
1459 | [Exposed=Window]
1460 | interface GeolocationPositionError {
1461 | const unsigned short PERMISSION_DENIED = 1;
1462 | const unsigned short POSITION_UNAVAILABLE = 2;
1463 | const unsigned short TIMEOUT = 3;
1464 | readonly attribute unsigned short code;
1465 | readonly attribute DOMString message;
1466 | };
1467 |
1468 | 1507 | The code attribute returns the value it was [=call back 1508 | with error|initialized to=] (see [[[#constants]]] for possible 1509 | values). 1510 |
1511 |1517 | The message attribute is a developer-friendly textual 1518 | description of the {{GeolocationPositionError/code}} attribute. 1519 |
1520 | 1531 |1538 | This specification defines a [=policy-controlled feature=] identified 1539 | by the token string "geolocation". Its [=policy-controlled 1540 | feature/default allowlist=] is [=default allowlist/'self'=]. 1541 |
1542 |1552 | For the purposes of user-agent automation and application testing, this 1553 | document defines geolocation emulations. 1554 |
1555 |1556 | Each [=top-level traversable=] has an associated emulated position 1557 | data, which is data representing {{GeolocationCoordinates}}, 1558 | {{GeolocationPositionError}} or null, initially null. 1559 |
1560 |1561 | To set emulated position data, given 1562 | [=navigable=] |navigable| and an |emulatedPositionData|: 1563 |
1564 |1584 | To get emulated position data, given {{Geolocation}} 1585 | |geolocation|: 1586 |
1587 |1612 | This specification builds upon earlier work in the industry, including 1613 | research by Aza Raskin, Google Gears Geolocation API, and 1614 | LocationAware.org. 1615 |
1616 |1617 | Thanks also to Alec Berntson, Alissa Cooper, Steve Block, Greg 1618 | Bolsinga, Lars Erik Bolstad, Aaron Boodman, Dave Burke, Chris Butler, 1619 | Max Froumentin, Shyam Habarakada, Marcin Hanclik, Ian Hickson, Brad 1620 | Lassey, Angel Machin, Cameron McCormack, Daniel Park, Stuart Parmenter, 1621 | Olli Pettay, Chris Prince, Arun Ranganathan, Carl Reed, Thomas 1622 | Roessler, Dirk Segers, Allan Thomson, Martin Thomson, Doug Turner, Erik 1623 | Wilde, Matt Womer, and Mohamed Zergaoui. 1624 |
1625 |1631 | Since publication as a W3C Recommendation in 2022, 1632 | Geolocation has received the following normative changes: 1633 |
1635 | Since First Public Working Draft in 2021, until it was published as a 1636 | W3C Recommendation in 2022, Geolocation received the 1637 | following normative changes: 1638 |
1639 |1650 | Since publication of the Second Edition in 2016, this specification 1651 | received the following substantive changes: 1652 |
1653 |1682 | See the commit history 1684 | for a complete list of changes. 1685 |
1686 |