详细问题描述
map 组件在getLocation后不刷新
能拿到具体的位置信息 getLocation 无报错
(DCloud产品不会有明显的bug,所以你遇到的问题大都是在特定环境下才能重现的问题,请仔细描述你的环境和重现方式,否则DCloud很难排查解决你的问题)
[内容]
<template>
<view>
<!-- <map id="map" style="width: 100vw; height: 100vh;" :latitude="latitude" :longitude="longitude"
:markers="markers" :circles="circles" ></map> -->
<map id="map" style="width: 100vw; height: 100vh;" :latitude="latitude" :longitude="longitude" :scale="scale" @updated="onShow"></map>
</view>
</template>
<script>
export default {
data() {
return {
latitude: 39.909, // 中心纬度
longitude: 116.39742, // 中心经度
scale:17 // 缩放级别,取值范围为5-18
}
},
onShow: function(){
const that = this;
uni.getLocation({
type: "gcj02",
success: function (res) {
// console.log(res.latitude)
// console.log(res.longitude)
that.latitude = res.latitude;
that.longitude = res.longitude;
},
fail:function(e){
console.log("失败了",e.errMsg);
uni.showToast({
title:"没有获取到位置信息,请先打开定位。"+e.errMsg,
icon:'none',
duration:3000
})
}
});
},
onLoad: function(){
},
methods: {
}
}
</script>
<style>
</style>
重现步骤
[步骤]
真机运行
[结果]
12:39:20.908 正在同步手机端程序文件...
12:39:21.184 4370 KB/s (1005252 bytes in 0.224s)
12:39:21.205 同步手机端程序文件完成
12:39:21.225 正在重启,如手机上HBuilder调试基座未启动,请手动启动...
12:39:22.347 App Show at App.vue:183
12:40:48.851 [Number] 28.599805 at pages\map\map.vue:23
12:40:48.872 [Number] 108.117443 at pages\map\map.vue:24

[期望]
[如果语言难以表述清晰,拍一个视频或截图,有图有真相]
IDE运行环境说明
HBuilderX 2.5.1
[HBuilder 或 HBuilderX。如果你用其他工具开发uni-app,也需要在此说明]
[IDE版本号]
2.5.1
[windows版本号]
windows 10
[mac版本号]
uni-app运行环境说明
[运行端是h5或app或某个小程序?]
app
[运行端版本号]
1.0.1.2
[项目是cli创建的还是HBuilderX创建的?如果是cli创建的,请更新到最新版cli再试]
HBuilderX
[编译模式是老模板模式还是新的自定义组件模式?]
App运行环境说明
[Android版本号]
9
[iOS版本号]
[手机型号]
华为 STK-AL00
[模拟器型号]
附件
[IDE问题请提供HBuilderX运行日志。菜单帮助-查看运行日志,点右键打开文件所在目录,将log文件压缩成zip包上传]
[App问题请提供可重现问题的代码片段,你补充的细一点,问题就解决的快一点]
[App安装包或H5地址]
[可重现代码片段]
联系方式
[QQ]
2313687649
[电话]
18785618024