• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Class (JsGeolocation)
2
3Implements the **PermissionRequest** object. For details about the sample code, see [onGeolocationShow](./arkts-basic-components-web-events.md#ongeolocationshow).
4
5> **NOTE**
6>
7> - The initial APIs of this component are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
8>
9> - The initial APIs of this class are supported since API version 8.
10>
11> - You can preview how this component looks on a real device, but not in DevEco Studio Previewer.
12
13## constructor
14
15constructor()
16
17Constructs a **JsGeolocation** object.
18
19**System capability**: SystemCapability.Web.Webview.Core
20
21## invoke
22
23invoke(origin: string, allow: boolean, retain: boolean): void
24
25Sets the geolocation permission status of a web page.
26
27**System capability**: SystemCapability.Web.Webview.Core
28
29**Parameters**
30
31| Name   | Type   | Mandatory | Description                                    |
32| ------ | ------- | ---- | ---------------------------------------- |
33| origin | string  | Yes  | Index of the origin.                              |
34| allow  | boolean | Yes  | Geolocation permission status.<br>The value **true** means to enable the geolocation permission, and **false** means the opposite.                            |
35| retain | boolean | Yes  | Whether the geolocation permission status can be saved to the system. You can manage the geolocation permissions saved to the system through the [GeolocationPermissions<sup>9+</sup>](./arkts-apis-webview-GeolocationPermissions.md) API.<br>The value **true** indicates that the geolocation permission status can be saved to the system, and **false** indicates the opposite.|
36