地图js:Page({ data: { markers: [], //地图参数: latitude: "", //纬度 longitude: "", //经度 }, clicktop(e) { let that = t_taro vue 微信小程序 webview 里 获取当前定位">
当前位置:   article > 正文

微信小程序获取当前位置_taro vue 微信小程序 webview 里 获取当前定位

taro vue 微信小程序 webview 里 获取当前定位

wxml:

<view>
    <button type="primary" bindtap="clicktop">地图</button>
</view>
  • 1
  • 2
  • 3

js:

Page({
	data: {
        markers: [],  //地图参数:
        latitude: "", //纬度 
        longitude: "",  //经度
    },
    clicktop(e) {
        let that = this;
        wx.getLocation({
          type: 'wgs84', 
          success(res){
            wx.openLocation({
              latitude: res.latitude,
              longitude: res.longitude,
              scale:18,
              success:function(res){
                wx.chooseLocation({
                  success(res){
                    console.log(res);
                  }
                })
              }
            })
          },
          fail:function(err){
            console.log(err);
          }
        })
	},
})
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
  

闽ICP备14008679号