283e6651aa
Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
444 B
TypeScript
20 lines
444 B
TypeScript
import Taro from '@tarojs/taro';
|
|
|
|
export type ClientGpsLocation = {
|
|
province?: string;
|
|
city?: string;
|
|
district?: string;
|
|
latitude: number;
|
|
longitude: number;
|
|
address?: string;
|
|
};
|
|
|
|
export async function tryGetClientGpsLocation(): Promise<ClientGpsLocation | null> {
|
|
try {
|
|
const loc = await Taro.getLocation({ type: 'gcj02' });
|
|
return { latitude: loc.latitude, longitude: loc.longitude };
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|