The **geolocation** module provides only basic functions such as GNSS positioning and network positioning.
> **NOTE**
>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use [`@ohos.geolocation`](js-apis-geolocation.md).
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - The APIs provided by this module are no longer maintained since API version 9. You are advised to use [geoLocationManager](js-apis-geoLocationManager.md) instead.
## Modules to Import
```
import geolocation from '@system.geolocation';
```
...
...
@@ -19,43 +19,46 @@ import geolocation from '@system.geolocation';
ohos.permission.LOCATION
## geolocation.getLocation
## geolocation.getLocation<sup>(deprecated)</sup>
getLocation(Object): void
Obtains the geographic location.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).
| timeout | number | No | Timeout duration, in milliseconds. The default value is **30000**.<br>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br>The value is a 32-digit positive integer. If the value set is less than or equal to **0**, the default value will be used. |
| coordType | string | No | Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**. |
| success | Function | No | Called when the operation is successful. |
| fail | Function | No | Called when the operation fails. |
| complete | Function | No | Called when the execution is complete |
| timeout | number | No| Timeout duration, in ms. The default value is **30000**.<br>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br>The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.|
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
The following values will be returned when the operation is successful.
**Return value of success()**
| Parameter | Type | Description |
| Name| Type| Description|
| -------- | -------- | -------- |
| longitude | number | Longitude|
| latitude | number | Latitude|
| altitude | number | Altitude|
| accuracy | number | Location accuracy |
| time | number | Time when the location is obtained |
| longitude | number | Longitude.|
| latitude | number | Latitude.|
| altitude | number | Altitude.|
| accuracy | number | Location accuracy.|
| time | number | Time when the location is obtained.|
One of the following error codes will be returned if the operation fails.
> This API is deprecated since API version 9. The location subsystem supports only two location types: GNSS positioning and network positioning. No APIs will be provided to query the supported location types.
| types | Array<string> | Available location types, ['gnss', 'network']|
**Example**
...
...
@@ -115,39 +121,42 @@ export default {
```
## geolocation.subscribe
## geolocation.subscribe<sup>(deprecated)</sup>
subscribe(Object): void
Listens to the geographical location. If this method is called multiple times, the last call takes effect.
Listens to the geographic location. If this method is called multiple times, the last call takes effect.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange).
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 801 | System location disabled.|
**Example**
...
...
@@ -167,11 +176,14 @@ export default {
```
## geolocation.unsubscribe
## geolocation.unsubscribe<sup>(deprecated)</sup>
unsubscribe(): void
Cancels listening to the geographical location.
Cancels listening to the geographic location.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange).
Obtains coordinate system types supported by the device.
> **NOTE**
> This API is deprecated since API version 9. The location subsystem supports only the wgs84 coordinate system. No APIs will be provided to query the supported coordinate system types.
>Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development.
> **NOTE**
>
>Download the release code, which is more stable, if you want to develop commercial functionalities. Download the master code if you want to get quick access to the latest features for your development.
-**Obtaining OpenHarmony release code**
...
...
@@ -168,7 +168,7 @@ You must install **Node.js** and HPM on your local PC. The installation procedur
To ensure the download performance, you are advised to download the source code or the corresponding solution from the image library of the respective site listed in the table below.
The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes]([Release Notes](../../release-notes/Readme.md).
The table below provides only the sites for downloading the latest OpenHarmony LTS code. For details about how to obtain the source code of earlier versions, see the [Release Notes](../../release-notes/Readme.md).
**Table 1** Sites for acquiring source code
...
...
@@ -181,7 +181,7 @@ The table below provides only the sites for downloading the latest OpenHarmony L
| **Source code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| **Source Code of the Latest Release**| **Version**| **Site**| **SHA-256 Checksum**| **Software Package Size**|
| Full code base (for mini, small, and standard systems)| 3.2 Beta4 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta4/code-v3.2-Beta4.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta4/code-v3.2-Beta4.tar.gz.sha256) | 19.0 GB |
| RK3568 standard system solution (binary)| 3.2 Beta4 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta4/dayu200_standard_arm32.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.2-Beta4/dayu200_standard_arm32.tar.gz.sha256) | 3.2 GB |
> The image repository is synchronized at 23:00 (UTC +8:00) every day.
Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have registered an SSH public key for access to GitHub. For details, see [Adding a new SSH key to your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account).\)
## cl.location.1 Deletion of the geoLocationManager.requestEnableLocation API in API Version 9
When the location function is disabled, your application can call the **geoLocationManager.requestEnableLocation** API to request the user to enable the location function. However, this API is seldom used, and user experience for this API is not very good because the user is not notified of the scenario in which your application uses the location information.
When the location function is disabled, your application can call the **geoLocationManager.requestEnableLocation** API to request the user to enable the location function. However, this API is seldom used because the user is not notified of the scenario in which your application uses the location information.
Therefore, your app shows a popup, asking the user to go to the settings page and enable the location function. In addition, the popup clearly states the scenarios in which the location information will be used, improving user experience.
Therefore, your application shows a popup, asking the user to go to the settings page and enable the location function. In addition, the popup clearly states the scenarios in which the location information will be used, improving user experience.