技术 · 思考 · 实践 · 成长

首页/微信小程序/正文

微信小程序 打开地图功能

微信小程序391 次阅读
 // 新版打开导航
    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);
            }
        })
    },


照顾好自己,如果尚有余力,记得保护美好的东西,不畏不惧赤诚善良。

评论交流

0 条评论 · 支持多级回复
验证码
暂无评论,来说说你的想法吧

相关文章

继续阅读