location.ts 362 B

123456789
  1. import { withResolvers } from "../promise";
  2. export type LocationType = 'wgs84' | 'gcj02';
  3. export function getFuzzyLocation(type?: LocationType) {
  4. const { promise, resolve, reject } = withResolvers<WechatMiniprogram.GetFuzzyLocationSuccessCallbackResult>();
  5. wx.getFuzzyLocation({ type: type ?? 'gcj02', success: resolve, fail: reject });
  6. return promise;
  7. }