uni-app获取当前的地理位置【uni.getLocation(OBJECT)】

    技术2022-07-10  121

    uni-app获取当前的地理位置【uni.getLocation(OBJECT)】

    在 manifest.json中配置 permission "permission": { "scope.userLocation": { "desc": "你的位置信息将用于小程序位置接口的效果展示" } }, 在需要的页面写 // 获取经纬度 uni.authorize({ scope: 'scope.userLocation', success() { uni.getLocation({ type: 'gcj02', //返回可以用于uni.openLocation的经纬度 success: function(res) { const latitude = res.latitude; const longitude = res.longitude; console.log('当前位置的经度:' + longitude); console.log('当前位置的纬度:' + latitude); } }); } }) 效果图
    Processed: 0.013, SQL: 9