.

- 发布:2020-09-11 15:40
- 更新:2022-09-27 10:46
- 阅读:923
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 10
HBuilderX类型: 正式
HBuilderX版本号: 2.8.11
手机系统: Android
手机系统版本号: Android 10
手机厂商: 华为
手机机型: magic TNY-AL00
页面类型: nvue
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
获取到当前地图中心点坐标
获取到当前地图中心点坐标
实际结果:
无回调
无回调
bug描述:
nvue页面getCenterLocation方法无回调

验证没有问题,请提供测试代码
<template>
<view>
<map id="map1" class="map1" :show-location="true" :latitude="latitude" :longitude="longitude"></map>
<button @click="getCenterLocation">getCenterLocation</button>
</view>
</template>
<script>
export default {
data() {
return {
latitude: 39.925539,
longitude: 116.279037
}
},
onReady() {
this.mapContext = uni.createMapContext("map1", this);
},
methods: {
getCenterLocation() {
this.mapContext.getCenterLocation({
success: (res) => {
console.log("getCenterLocation");
console.log(res);
}
})
}
}
}
</script>
<style>
.map1 {
width: 750rpx;
height: 400px;
}
</style>

曹大宝 (作者) - 嗷呜嗷呜嗷呜
<template>
<view>
<map :style="{width: map_width,height:map_height}"
:controls="controls"
:latitude="latitude"
:longitude="longitude"
:markers="covers"
:scale = "scale"
:polyline = "polyline"
:circles = "circles"
enable-3D
show-location
id="map1"
ref = "map1"
:show-location="true"
@regionchange = "regionchange"
@markertap = "markertap"
>
<!-- @tap = "test" -->
</map>
</view>
<script>
const conf = uni.getStorageSync('conf');
export default {
components: {uniNavBar},
data() {
return {
data:{},
map_width:"",
map_height:"",
btn:"",
id:0,
controls: [],
polyline:[],
circles:[],
scale:20,
title:"map",
latitude: 39.909,
longitude: 116.39742,
covers: [],
statusBarHeight:"",
detail:{},
id:"map1",
address:""
}
},
methods: {
regionchange(e){
this.mapContext.getCenterLocation({
success(res) {
console.log(res);
console.log(1234);
},
fail(err){
console.log(err);
console.log(12345);
},
complete(e) {
console.log(3);
console.log(123456);
}
})
}
},
}
</template>
曹大宝 (作者)
enable-3D
show-location
id="map1"
ref = "map1"
@regionchange = "regionchange"
@markertap = "markertap"
>
<!-- @tap = "test" -->
</map>
</view>
<script>
const conf = uni.getStorageSync('conf');
export default {
components: {uniNavBar},
data() {
return {
data:{},
map_width:"",
map_height:"",
btn:"",
id:0,
controls: [],
polyline:[],
circles:[],
scale:20,
title:"map",
latitude: 39.909,
longitude: 116.39742,
covers: [],
statusBarHeight:"",
detail:{},
id:"map1",
address:""
}
},
methods: {
regionchange(e){
this.mapContext.getCenterLocation({
success(res) {
console.log(res);
console.log(1234);
},
fail(err){
console.log(err);
console.log(12345);
},
complete(e) {
console.log(3);
console.log(123456);
}
})
}
},
}
</template>
2020-09-16 11:25