• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit LocationKit
19 */
20
21/**
22 * @syscap SystemCapability.Location.Location.Lite
23 * @deprecated since 9
24 * @useinstead ohos.geoLocationManager/geoLocationManager.Location
25 */
26export interface GeolocationResponse {
27  /**
28   * Longitude.
29   * @since 3
30   */
31  longitude: number;
32
33  /**
34   * Latitude.
35   * @since 3
36   */
37  latitude: number;
38
39  /**
40   * Altitude.
41   * @since 3
42   */
43  altitude: number;
44
45  /**
46   * Location accuracy.
47   * @since 3
48   */
49  accuracy: number;
50
51  /**
52   * Time when the location is obtained.
53   * @since 3
54   */
55  time: number;
56}
57
58/**
59 * @syscap SystemCapability.Location.Location.Lite
60 * @permission ohos.permission.LOCATION
61 * @deprecated since 9
62 * @useinstead ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest
63 */
64export interface GetLocationOption {
65  /**
66   * Timeout duration, in milliseconds.
67   * For the rich device, the default value is 30000.
68   * For the lite wearable device, the default value is 180000.
69   * The timeout duration is necessary in case no result is returned if 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.
70   * The value is a 32-digit positive integer.
71   * If the value set is less than or equal to 0, the default value will be used.
72   * @since 3
73   */
74  timeout?: number;
75
76  /**
77   * Coordinate system type. Available types can be obtained using getSupportedCoordTypes.
78   * The default type is wgs84.
79   * @since 3
80   */
81  coordType?: string;
82
83  /**
84   * Called when the geographic location is obtained.
85   * @since 3
86   */
87  success?: (data: GeolocationResponse) => void;
88
89  /**
90   * Called when the location types fail to be obtained
91   * @since 3
92   */
93  fail?: (data: string, code: number) => void;
94
95  /**
96   * Called when the execution is completed.
97   * @since 3
98   */
99  complete?: () => void;
100}
101
102/**
103 * @syscap SystemCapability.Location.Location.Lite
104 * @deprecated since 9
105 */
106export interface GetLocationTypeResponse {
107  /**
108   * @since 3
109   */
110  types: Array<string>;
111}
112
113/**
114 * @syscap SystemCapability.Location.Location.Lite
115 * @deprecated since 9
116 */
117export interface GetLocationTypeOption {
118  /**
119   * Called when the location types are obtained.
120   * @since 3
121   */
122  success?: (data: GetLocationTypeResponse) => void;
123
124  /**
125   * Called when the location types fail to be obtained.
126   * @since 3
127   */
128  fail?: (data: string, code: number) => void;
129
130  /**
131   * Called when the execution is completed.
132   * @since 3
133   */
134  complete?: () => void;
135}
136
137/**
138 * @syscap SystemCapability.Location.Location.Lite
139 * @permission ohos.permission.LOCATION
140 * @deprecated since 9
141 * @useinstead ohos.geoLocationManager/geoLocationManager.LocationRequest
142 */
143export interface SubscribeLocationOption {
144  /**
145   * Coordinate system type. Available types can be obtained using getSupportedCoordTypes.
146   * The default type is wgs84.
147   * @since 3
148   */
149  coordType?: string;
150
151  /**
152   * Called whenever the geographical location changes.
153   * @since 3
154   */
155  success: (data: GeolocationResponse) => void;
156
157  /**
158   * Called when the listening fails.
159   * @since 3
160   */
161  fail?: (data: string, code: number) => void;
162}
163
164/**
165 * @syscap SystemCapability.Location.Location.Lite
166 * @deprecated since 9
167 * @useinstead ohos.geoLocationManager/geoLocationManager
168 */
169export default class Geolocation {
170  /**
171   * Obtains the geographic location.
172   * @permission ohos.permission.LOCATION
173   * @param options Options.
174   * @deprecated since 9
175   * @useinstead ohos.geoLocationManager/geoLocationManager.getCurrentLocation
176   */
177  static getLocation(options?: GetLocationOption): void;
178
179  /**
180   * Obtains the location types supported by the system.
181   * @param options Options.
182   * @deprecated since 9
183   */
184  static getLocationType(options?: GetLocationTypeOption): void;
185
186  /**
187   * Listens to the geographical location. If this method is called multiple times, the last call takes effect.
188   * @permission ohos.permission.LOCATION
189   * @param options Options.
190   * @deprecated since 9
191   * @useinstead ohos.geoLocationManager/geoLocationManager.on#event:locationChange
192   */
193  static subscribe(options: SubscribeLocationOption): void;
194
195  /**
196   * Cancels listening to the geographical location.
197   * @permission ohos.permission.LOCATION
198   * @deprecated since 9
199   * @useinstead ohos.geoLocationManager/geoLocationManager.off#event:locationChange
200   */
201  static unsubscribe(): void;
202
203  /**
204   * Obtains the supported coordinate system types.
205   * @returns A string array of the supported coordinate system types, for example, ['wgs84'].
206   * @deprecated since 9
207   */
208  static getSupportedCoordTypes(): Array<string>;
209}
210