diff --git a/api/@system.geolocation.d.ts b/api/@system.geolocation.d.ts index cd1b299bfbc7bf7b0909e8566500aca25ff5e19c..8a26be6c0bd1d579c5015ee2f8bf9233f48047b5 100644 --- a/api/@system.geolocation.d.ts +++ b/api/@system.geolocation.d.ts @@ -48,106 +48,125 @@ export interface GeolocationResponse { time: number; } +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export interface GetLocationOption { + /** + * Timeout duration, in milliseconds. + * For the rich device, the default value is 30000. + * For the lite wearable device, the default value is 180000. + * 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. + * 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. + * @since 3 + */ + timeout?: number; + + /** + * Coordinate system type. Available types can be obtained using getSupportedCoordTypes. + * The default type is wgs84. + * @since 3 + */ + coordType?: string; + + /** + * Called when the geographic location is obtained. + * @since 3 + */ + success?: (data: GeolocationResponse) => void; + + /** + * Called when the location types fail to be obtained + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + /** * @syscap SystemCapability.Location.Location.Lite */ export interface GetLocationTypeResponse { /** - * Available location types, ['gps', 'network']. * @since 3 */ types: Array; } +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export interface GetLocationTypeOption { + /** + * Called when the location types are obtained. + * @since 3 + */ + success?: (data: GetLocationTypeResponse) => void; + + /** + * Called when the location types fail to be obtained. + * @since 3 + */ + fail?: (data: string, code: number) => void; + + /** + * Called when the execution is completed. + * @since 3 + */ + complete?: () => void; +} + +/** + * @syscap SystemCapability.Location.Location.Lite + */ +export interface SubscribeLocationOption { + /** + * Coordinate system type. Available types can be obtained using getSupportedCoordTypes. + * The default type is wgs84. + * @since 3 + */ + coordType?: string; + + /** + * Called whenever the geographical location changes. + * @since 3 + */ + success: (data: GeolocationResponse) => void; + + /** + * Called when the listening fails. + * @since 3 + */ + fail?: (data: string, code: number) => void; +} + /** * @syscap SystemCapability.Location.Location.Lite */ export default class Geolocation { /** * Obtains the geographic location. - * @param options - */ - static getLocation(options?: { - /** - * Timeout duration, in milliseconds. The default value is 30000. - * 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. - * 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. - * @since 3 - */ - timeout?: number; - - /** - * Coordinate system type. Available types can be obtained by getSupportedCoordTypes. The default type is wgs84. - * @since 3 - */ - coordType?: string; - - /** - * Called when the geographic location is obtained. - * @since 3 - */ - success?: (data: GeolocationResponse) => void; - - /** - * Called when the location types fail to be obtained - * @since 3 - */ - fail?: (data: any, code: number) => void; - - /** - * Called when the execution is completed. - * @since 3 - */ - complete?: () => void; - }): void; - - /** - * Obtains the supported location types. - * @param options - */ - static getLocationType(options?: { - /** - * Called when the location types are obtained. - * @since 3 - */ - success?: (data: GetLocationTypeResponse) => void; - - /** - * Called when the location types fail to be obtained. - * @since 3 - */ - fail?: (data: any, code: number) => void; - - /** - * Called when the execution is completed. - * @since 3 - */ - complete?: () => void; - }): void; + * @param options Options. + */ + static getLocation(options?: GetLocationOption): void; /** - * Listens to the geographical location. If this method is called multiple times, the last call takes effect. - * @param options + * Obtains the location types supported by the system. + * @param options Options. */ - static subscribe(options: { - /** - * Coordinate system type. Available types can be obtained by getSupportedCoordTypes. The default type is wgs84. - * @since 3 - */ - coordType?: string; - - /** - * Called when the geographical location changes. - * @since 3 - */ - success: (data: GeolocationResponse) => void; + static getLocationType(options?: GetLocationTypeOption): void; - /** - * Called when the listening fails. - * @since 3 - */ - fail?: (data: any, code: number) => void; - }): void; + /** + * Listens to the geographical location. If this method is called multiple times, the last call takes effect. + * @param options Options. + */ + static subscribe(options: SubscribeLocationOption): void; /** * Cancels listening to the geographical location. @@ -155,8 +174,8 @@ export default class Geolocation { static unsubscribe(): void; /** - * Obtains coordinate system types supported by the device. - * @returns A string array of the supported coordinate system types. For details about the value, see coordType. + * Obtains the supported coordinate system types. + * @returns A string array of the supported coordinate system types, for example, ['wgs84']. */ static getSupportedCoordTypes(): Array; }