小程序根据经纬度导航

小程序微信授权位置,根据经纬度,弹出手机自带地图APP,去导航。

1,WXML

2,app.json

 "permission": {

        "scope.userLocation": {

            "desc": "你的位置信息将用于小程序定位"

        }

3,js

 wx.getLocation({

            type: 'gcj02', //返回可以用于 wx.openLocation 的经纬度

            success (res) {

                console.log(res)

              const latitude = this.data.latitude //纬度

              const longitude = this.data.longitude //经度

              wx.openLocation({

                latitude,

                longitude,

                scale: 20,

                name:this.data.name, // 名称

                address:this.data.addr //详细地址

              })

            }

           })

你可能感兴趣的:(前端开发,小程序专题,小程序,前端,交互,微信小程序,百度小程序)