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