import { GetLocationOptions } from "./GetLocationOptions"; import { LocationChangeEvent } from "./LocationChangeEvent"; import { LocationInfo } from "./LocationInfo"; import { OpenLocationOptions } from "./OpenLocationOptions"; import { StartLocationUpdateBackgroundOptions } from "./StartLocationUpdateBackgroundOptions"; import { StartLocationUpdateOptions } from "./StartLocationUpdateOptions"; import { StopLocationUpdateOptions } from "./StopLocationUpdateOptions"; export declare class LocationAPI { /** * 获取当前地理位置信息。调用前需要 [用户授权](https://open.kuaishou.com/docs/develop/api-next/open/authorize/ks.authorize) `scope.userLocation`。 * @version {"kma":"1.26.1","ide":"1.47.0"} * @param options * @returns * @errinfo [{"errMsg":"no permission","errDesc":"无定位权限"},{"errMsg":"not authorize","errDesc":"未授权"}] * @example * ```javascript * const location = await ks.getLocation(); * * ``` * */ getLocation(options?: GetLocationOptions): Promise; /** * 监听实时地理位置信息变化事件。 * @param callback 实时地理位置信息变化事件的回调函数 * * @example * ```javascript * await ks.startLocationUpdate(); * // 或者 * await ks.startLocationUpdateBackground(); * * ks.onLocationChange((location) => { * // * }); * * setTimeout(async () => { * await ks.stopLocationUpdate(); * }, 3000); * * ``` * */ onLocationChange(callback: (event: LocationChangeEvent) => void): void; /** * 取消监听实时地理位置信息变化事件。不传入 `callback` 则取消所有监听。 * @param callback 实时地理位置信息变化事件的回调函数 * * @example * ```javascript * ks.offLocationChange(); * * ``` * */ offLocationChange(callback?: (event: LocationChangeEvent) => void): void; /** * 开始监听实时地理位置信息变化事件。小程序进入前后台时均接收实时地理位置信息。调用前需要 [用户授权](https://open.kuaishou.com/docs/develop/api-next/open/authorize/ks.authorize) `scope.userLocationBackground`。 * @param options * @returns * * @example * ```javascript * await ks.startLocationUpdateBackground(); * * ks.onLocationChange((location) => { * // * }); * * ``` * */ startLocationUpdateBackground(options?: StartLocationUpdateBackgroundOptions): Promise; /** * 开始监听实时地理位置信息变化事件。小程序进入前台时才接收实时地理位置信息。调用前需要 [用户授权](https://open.kuaishou.com/docs/develop/api-next/open/authorize/ks.authorize) `scope.userLocation`。 * @param options * @returns * * @example * ```javascript * await ks.startLocationUpdate(); * * ks.onLocationChange((location) => { * // * }); * * ``` * */ startLocationUpdate(options?: StartLocationUpdateOptions): Promise; /** * 停止监听实时地理位置信息变化事件。小程序在前后台都停止接收实时地理位置信息。 * @param options * @returns * * @example * ```javascript * await ks.stopLocationUpdate(); * * ``` * */ stopLocationUpdate(options?: StopLocationUpdateOptions): Promise; /** * 使用内置地图查看位置。 * @version {"kma":"1.64.0","ide":"1.47.0"} * @param options * @returns * * @example * ```javascript * ks.getLocation({ * type: 'gcj02', * success(res) { * const latitude = res.latitude; * const longitude = res.longitude; * ks.openLocation({ * latitude, * longitude, * }); * }, * }); * * ``` * */ openLocation(options?: OpenLocationOptions): Promise; }