我是靠谱客的博主 悦耳学姐,这篇文章主要介绍微信使用精准位置 wx.getLocation步骤,现在分享给大家,希望可以做个参考。

  1. 微信小程序 ->开发设置->接口设置->开通 wx.getLocation

  2. 申请理由:应当前业务涉及周边服务推荐需要,需获取用户地理位置信息

  3. 调试基础库:2.24.4

  4. 在app.json中添加
    “requiredPrivateInfos”:[
    “getLocation”
    ],
    在这里插入图片描述

  5. 页面使用:

        wx.getLocation({
            type: 'gcj02',
            success (res) {
                console.log('经纬度',res)
                const latitude = res.latitude
                const longitude = res.longitude
               wx.setStorageSync('latitude', latitude)
               wx.setStorageSync('longitude', longitude)
            },
            fail(res){
                console.log('获取经纬度失败',res)
            }
            
        })

最后

以上就是悦耳学姐最近收集整理的关于微信使用精准位置 wx.getLocation步骤的全部内容,更多相关微信使用精准位置内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部