<template>
<view>
<map :latitude="latitude" :longitude="longitude" style="width: 100%;" :style="{height: mapHeight + 'px'}"></map>
</view>
</template>
<script>
export default {
data() {
return {
latitude: 31.98,
longitude: 120.88,
}
},
onShow() {
var that = this
const _this = this;
uni.getLocation({
type: 'gcj02',
success: function(res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
that.latitude = res.latitude;
that.longitude = res.longitude;
},
fail: function(res) {
console.log('定位失败')
}
}),
//设置height高度
uni.getSystemInfo({
success: (res) => {
_this.mapHeight = res.screenHeight - res.statusBarHeight
_this.mapHeight = _this.mapHeight
}
})
},
methods: {
}
}
</script>
<style>
</style>

- 发布:2022-04-13 23:05
- 更新:2022-04-13 23:16
- 阅读:274
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows 11 21H2 22000.556
HBuilderX类型: Alpha
HBuilderX版本号: 3.4.5
手机系统: Android
手机系统版本号: Android 9.0
手机厂商: 模拟器
手机机型: 夜神模拟器
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
如示例
如示例
预期结果:
success
success
实际结果:
fail
fail
bug描述:
使用官方文档中的获取定位uni.getLocation,运行安卓App基座,一直返回fail,真机测试也无法获取位置,真机小米10,安卓12,miui13.4
高德定位api和高德地图api都确认过,权限模块也都确认过
