微信小程序获取经纬度并转换为地址信息

69 阅读1分钟

app.json配置

"requiredPrivateInfos": [
    "getLocation"
],
"permission": {
    "scope.userLocation": {
        "desc": "你的位置信息将用于小程序位置接口的效果展示"
    }
}

页面调用

wx.getLocation({
    type: 'wgs84',
    success (res) {
        console.log(res);
        const longitude = res.longitude; // 经度
        const latitude = res.latitude; // 纬度
        const speed = res.speed;
        const accuracy = res.accuracy;
    }
})