Name Date Size

..25-Oct-20244 KiB

.gitignoreH A D25-Oct-202493

AppScope/H25-Oct-20244 KiB

build-profile.json5H A D25-Oct-20241.1 KiB

entry/H25-Oct-20244 KiB

hvigor/H25-Oct-20244 KiB

hvigorfile.jsH A D25-Oct-2024168

hvigorwH A D25-Oct-20242.1 KiB

hvigorw.batH A D25-Oct-20242 KiB

oh-package.json5H A D25-Oct-2024813

ohosTest.mdH A D25-Oct-2024714

position/H25-Oct-20244 KiB

README.mdH A D25-Oct-20242.3 KiB

README_zh.mdH A D25-Oct-20243.5 KiB

screenshots/devices/zh/H25-Oct-20244 KiB

README.md

1# Geolocation
2
3### Introduction
4
5This sample shows how to use **geolocation** APIs to implement location services.
6
7In this example, we'll use [Geolocation](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-geolocation.md) APIs to obtain the longitude and latitude of the current location, and use [HTTP](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/apis/js-apis-http.md) APIs to obtain the city where the longitude and latitude are located. With the [AlphabetIndexer](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md) APIs, we can also quickly locate the container display area based on the logical structure.
8
9How to Use
10
111. Go to the home page and touch a popular city in the popular city list. The delivery address will be updated to the selected city. Alternatively, touch the alphabetic index bar on the right to quickly locate the desired city. If the city is divided into districts, you can click the desired district to update the delivery address to that district.
12
132. If your test device supports the GPS function, you can touch the location icon above the popular city list to locate the city where you settle. The city next to the location icon will be updated accordingly. Current city data is analog data.
14
15
16### Preview
17
18![](screenshots/devices/zh/position.png)
19
20### Required Permissions
21
22Using network sockets: [ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/permission-list.md)
23
24Obtaining location information while running in the foreground: [ohos.permission.LOCATION](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/permission-list.md)
25
26Obtaining location information while running in the background: [ohos.permission.LOCATION_IN_BACKGROUND](https://gitee.com/openharmony/docs/blob/master/en/application-dev/security/permission-list.md)
27
28### Dependency
29
30N/A
31
32### Constraints
33
341. This sample can only be run on standard-system devices. To use GPS positioning, the test device must support the GPS function.
35
362. This sample demonstrates the stage model, which supports only the SDK of API version 9 (SDK version: 3.2.11.9). 
37
383. DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100) must be used.
39