this.mapContext = uni.createMapContext("map", this);
this.mapContext.getCenterLocation({
type: 'gcj02',
success: (res) => {
uni.showModal({
title: '位置信息',
content: (res.longitude).toFixed(2) + '/' + (res.latitude).toFixed(2)
});
console.log(res);
let address = {
latitude: res.latitude,
longitude: res.longitude
}
this.markers[0].longitude = address.longitude;
this.markers[0].latitude = address.latitude;
console.log("地址")
console.log(address)
this.$emit('longLatDetail', address)
},
fail: (err) => {
console.log(this.latitude)
console.log('获取当前地图中心的经纬度2', err);
}
})

- 发布:2024-01-06 10:29
- 更新:2024-01-06 11:18
- 阅读:377
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: WIN10 LTSC
HBuilderX类型: 正式
HBuilderX版本号: 3.99
手机系统: Android
手机系统版本号: Android 12
手机厂商: 华为
手机机型: mate40
页面类型: nvue
vue版本: vue3
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
this.mapContext.getCenterLocation({
type: 'gcj02',
success: (res) => {
以下都不执行
this.mapContext.getCenterLocation({
type: 'gcj02',
success: (res) => {
以下都不执行
预期结果:
预期结果是能出来res的值
预期结果是能出来res的值
实际结果:
res没任何值,并且没有触发
res没任何值,并且没有触发
bug描述:
uniapp subnvue 中是用map的方法 getRegion getCenterLocation等方法不启作用
1 个回复
hzpb2013 (作者)
父级和子级都用nvue就解决这个问题了