飞翔的青蛙
飞翔的青蛙
  • 发布:2021-05-31 10:39
  • 更新:2021-08-31 19:21
  • 阅读:1823

暂不支持小程序的 onLocationChange 监听实时地理位置变化事件?

分类:uni-app

uni-app官方文档没找到对应小程序这个api 是不是暂不支持,只能跨端判断使用了

2021-05-31 10:39 负责人:无 分享
已邀请:
飞翔的青蛙

飞翔的青蛙 (作者)

我也没在文档搜索到,可能需要跨端判断了

  • 1***@qq.com

    怎么样实现。有没有示例

    2021-08-31 17:48

  • 飞翔的青蛙 (作者)

    回复 1***@qq.com: 楼下

    2021-08-31 19:21

飞翔的青蛙

飞翔的青蛙 (作者)

// #ifdef MP-WEIXIN  
                             wx.startLocationUpdate({  
                    success: (res) => {  
                      console.log('startLocationUpdate-res', res)  
                      wx.onLocationChange((localeRes) => { //调用实时获取定位  
                        console.warn("change返回:",localeRes)  
                        // 获取后停止实时定位  
                        wx.stopLocationUpdate({  
                          success: (stopUpdateRes) => {  
                            console.log("stopLocationUpdate:",stopUpdateRes);  
                            wx.offLocationChange();  
                                            resolve(localeRes)  
                          },  
                          fail: (stopUpdateErr)=>{  
                            console.error("stopLocationUpdate错误",stopUpdateErr)  
                                            resolve(localeRes)  
                          }  
                        })  

                      });  

                    },  
                    fail: (err) => {  
                      console.error("startLocationUpdate错误",err)  
                                reject(err)  
                    }  
                  })  
// #endif

该问题目前已经被锁定, 无法添加新回复