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 * @type { number } 30 * @since 3 31 */ 32 longitude: number; 33 34 /** 35 * Latitude. 36 * @type { number } 37 * @since 3 38 */ 39 latitude: number; 40 41 /** 42 * Altitude. 43 * @type { number } 44 * @since 3 45 */ 46 altitude: number; 47 48 /** 49 * Location accuracy. 50 * @type { number } 51 * @since 3 52 */ 53 accuracy: number; 54 55 /** 56 * Time when the location is obtained. 57 * @type { number } 58 * @since 3 59 */ 60 time: number; 61} 62 63/** 64 * @syscap SystemCapability.Location.Location.Lite 65 * @permission ohos.permission.LOCATION 66 * @deprecated since 9 67 * @useinstead ohos.geoLocationManager/geoLocationManager.CurrentLocationRequest 68 */ 69export interface GetLocationOption { 70 /** 71 * Timeout duration, in milliseconds. 72 * For the rich device, the default value is 30000. 73 * For the lite wearable device, the default value is 180000. 74 * 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. 75 * The value is a 32-digit positive integer. 76 * If the value set is less than or equal to 0, the default value will be used. 77 * @type { ?number } 78 * @since 3 79 */ 80 timeout?: number; 81 82 /** 83 * Coordinate system type. Available types can be obtained using getSupportedCoordTypes. 84 * The default type is wgs84. 85 * @type { ?string } 86 * @since 3 87 */ 88 coordType?: string; 89 90 /** 91 * Called when the geographic location is obtained. 92 * @type { ?function } 93 * @since 3 94 */ 95 success?: (data: GeolocationResponse) => void; 96 97 /** 98 * Called when the location types fail to be obtained 99 * @type { ?function } 100 * @since 3 101 */ 102 fail?: (data: string, code: number) => void; 103 104 /** 105 * Called when the execution is completed. 106 * @type { ?function } 107 * @since 3 108 */ 109 complete?: () => void; 110} 111 112/** 113 * @syscap SystemCapability.Location.Location.Lite 114 * @deprecated since 9 115 */ 116export interface GetLocationTypeResponse { 117 /** 118 * @type { Array<string> } 119 * @since 3 120 */ 121 types: Array<string>; 122} 123 124/** 125 * @syscap SystemCapability.Location.Location.Lite 126 * @deprecated since 9 127 */ 128export interface GetLocationTypeOption { 129 /** 130 * Called when the location types are obtained. 131 * @type { ?function } 132 * @since 3 133 */ 134 success?: (data: GetLocationTypeResponse) => void; 135 136 /** 137 * Called when the location types fail to be obtained. 138 * @type { ?function } 139 * @since 3 140 */ 141 fail?: (data: string, code: number) => void; 142 143 /** 144 * Called when the execution is completed. 145 * @type { ?function } 146 * @since 3 147 */ 148 complete?: () => void; 149} 150 151/** 152 * @syscap SystemCapability.Location.Location.Lite 153 * @permission ohos.permission.LOCATION 154 * @deprecated since 9 155 * @useinstead ohos.geoLocationManager/geoLocationManager.LocationRequest 156 */ 157export interface SubscribeLocationOption { 158 /** 159 * Coordinate system type. Available types can be obtained using getSupportedCoordTypes. 160 * The default type is wgs84. 161 * @type { ?string } 162 * @since 3 163 */ 164 coordType?: string; 165 166 /** 167 * Called whenever the geographical location changes. 168 * @type { ?function } 169 * @since 3 170 */ 171 success: (data: GeolocationResponse) => void; 172 173 /** 174 * Called when the listening fails. 175 * @type { ?function } 176 * @since 3 177 */ 178 fail?: (data: string, code: number) => void; 179} 180 181/** 182 * @syscap SystemCapability.Location.Location.Lite 183 * @deprecated since 9 184 * @useinstead ohos.geoLocationManager/geoLocationManager 185 */ 186export default class Geolocation { 187 /** 188 * Obtains the geographic location. 189 * @permission ohos.permission.LOCATION 190 * @param options Options. 191 * @deprecated since 9 192 * @useinstead ohos.geoLocationManager/geoLocationManager.getCurrentLocation 193 */ 194 static getLocation(options?: GetLocationOption): void; 195 196 /** 197 * Obtains the location types supported by the system. 198 * @param options Options. 199 * @deprecated since 9 200 */ 201 static getLocationType(options?: GetLocationTypeOption): void; 202 203 /** 204 * Listens to the geographical location. If this method is called multiple times, the last call takes effect. 205 * @permission ohos.permission.LOCATION 206 * @param options Options. 207 * @deprecated since 9 208 * @useinstead ohos.geoLocationManager/geoLocationManager.on#event:locationChange 209 */ 210 static subscribe(options: SubscribeLocationOption): void; 211 212 /** 213 * Cancels listening to the geographical location. 214 * @permission ohos.permission.LOCATION 215 * @deprecated since 9 216 * @useinstead ohos.geoLocationManager/geoLocationManager.off#event:locationChange 217 */ 218 static unsubscribe(): void; 219 220 /** 221 * Obtains the supported coordinate system types. 222 * @returns A string array of the supported coordinate system types, for example, ['wgs84']. 223 * @deprecated since 9 224 */ 225 static getSupportedCoordTypes(): Array<string>; 226} 227