计算机网络/计算机科学与应用/系统/运维/开发

微信小程序 打开地图功能

 // 新版打开导航
    openMap:function(e){
        var that = this 
        wx.getLocation({
            type: 'gcj02', //返回可以用于wx.openLocation的经纬度
            success (res) {
                const name = that.data.address_name
                const address = that.data.address_details
                const latitude = Number(that.data.latitude)
                const longitude = Number(that.data.longitude)
                console.log(name)
                console.log(address)
                console.log(latitude)
                console.log(longitude)
                wx.openLocation({
                    name:that.data.address_name,
                    address:that.data.address_details,
                    latitude,
                    longitude,
                    scale: 16
                })
            }, 
            fail (res){
                console.error("res="+res);
            }
        })
    },


学会在学习中寻找乐趣,学会乐在其中并保持热情

评论

^