minigame-std
Version:
Cross-platform standard library for WeChat minigame and web browsers with unified APIs for crypto, fs, fetch, storage, and more.
53 lines (48 loc) • 1.15 kB
TypeScript
import { AsyncIOResult } from 'happy-rusty';
/**
* geo 坐标。
* @since 1.7.0
* @example
* ```ts
* import { lbs, type GeoPosition } from 'minigame-std';
*
* const result = await lbs.getCurrentPosition();
* if (result.isOk()) {
* const pos: GeoPosition = result.unwrap();
* console.log('纬度:', pos.latitude, '经度:', pos.longitude);
* }
* ```
*/
interface GeoPosition {
/**
* 纬度。
*/
latitude: number;
/**
* 经度。
*/
longitude: number;
}
/**
* 位置服务模块(Location Based Service),提供获取地理位置坐标的功能。
* @module lbs
*/
/**
* 获取当前 geo 坐标。
* @returns 当前经纬度。
* @since 1.7.0
* @example
* ```ts
* const result = await getCurrentPosition();
* if (result.isOk()) {
* const pos = result.unwrap();
* console.log('纬度:', pos.latitude);
* console.log('经度:', pos.longitude);
* } else {
* console.error('获取位置失败:', result.unwrapErr());
* }
* ```
*/
declare function getCurrentPosition(): AsyncIOResult<GeoPosition>;
export { getCurrentPosition };
export type { GeoPosition };