收藏
回答

鸿蒙系统微信 公众号内嵌h5 获取微信定位 失败,如何解决?

window.wx.ready(() => {
  window.wx.getLocation({
    type: 'gcj02',
    isHighAccuracy: true, // 精准定位
    highAccuracyExpireTime: 3000,
    async success(res: any) {
      // 获取城市名称
      const { bdjLng, bdjLat } = await gcj02ToBd09(Number(res.longitude), Number(res.latitude))
      const location = await getLocation(bdjLng, bdjLat)
      if (!userProvince.province)
        userProvince.updateProvince(location)
    },
    cancel: async () => {
      console.log('微信定位取消的回调')
    },
    fail: async () => {
      console.log('微信定位失败的回调')
    }
  })
})


回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容