<template>
<view>
<map id="test_map" style="width: 750rpx; height: 300px;" :show-location="true"
:longitude="map.longitude" :latitude="map.latitude">
</map>
<button @click="dingwei">定位到"北京西站"</button>
</view>
</template>
<script>
export default {
data() {
return {
map: {
longitude: '',//经度
latitude: '',//纬度
}
}
},
onLoad() {
let _this = this;
uni.getLocation({
type: 'gcj02',
success: function (res) {
_this.map.longitude = res.longitude;
_this.map.latitude = res.latitude;
}
});
},
methods: {
dingwei(){
//官方API uni.createMapContext(mapId,this)
//其中API对应方法之一: moveToLocation(OBJECT) //将地图中心移动到当前定位点,需要配合map组件的show-location使用
//需要实现的目标:定位平移 到指定坐标位置.比如案例中定位到"北京西站"
//实际结果: 在iPhone8中,定位平移 到本人真实的当前位置
uni.createMapContext('test_map', this).moveToLocation({
//该固定坐标为高德地图拾取,位置:北京西站
latitude: 39.894589,
longitude: 116.32125,
success: function(res){
console.log("此处无回调!!!本条信息未在控制台打印");
console.log(res);
}
});
}
}
}
</script>
<style scoped>
</style>

- 发布:2020-07-17 18:33
- 更新:2020-08-07 11:51
- 阅读:2352
【报Bug】官方API "位置" uni.createMapContext(mapId,this) 中 方法 moveToLocation 在nvue中无法 定位平移 到指定经纬度的位置
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 2.7.14
手机系统: iOS
手机系统版本号: iOS 13.4
手机厂商: 苹果
手机机型: iPhone8
页面类型: nvue
打包方式: 云端
项目创建方式: HBuilderX
操作步骤:
预期结果:
调用 uni.createMapContext(mapId,this).moveToLocation(object) 时 界面定位平移到指定的经纬度位置
调用 uni.createMapContext(mapId,this).moveToLocation(object) 时 界面定位平移到指定的经纬度位置
实际结果:
调用 uni.createMapContext(mapId,this).moveToLocation(object) 时 界面定位平移到本地真实定位位置
调用 uni.createMapContext(mapId,this).moveToLocation(object) 时 界面定位平移到本地真实定位位置
bug描述:
官方API "位置" uni.createMapContext(mapId,this) 中 方法 moveToLocation 在nvue中无法 定位平移 到指定经纬度的位置
其中在 vue里面 moveToLocation 方法正常可以 定位平移 到指定的经纬度位置
"moveToLocation 在 vue 里面功能正常"
"moveToLocation 在 vue 里面功能正常"
"moveToLocation 在 vue 里面功能正常"
"moveToLocation 在 nvue 里面功能异常,无法指定 经纬度 两个参数"
"moveToLocation 在 nvue 里面功能异常,无法指定 经纬度 两个参数"
"moveToLocation 在 nvue 里面功能异常,无法指定 经纬度 两个参数"

4***@qq.com (作者)
地图就卡在这里了,麻烦管理员能够尽快发现,能够争取在下一个版本中修改功能!
测试文件在附件里面,直接下载运行就行!
vue 和 nvue 代码一样,但是运行结果有明显区别!
非常紧急!!!
非常紧急!!!
非常紧急!!!

HBuilderX 2.8.2+ 已修复
-
4***@qq.com (作者)
2.8.2.20200726 修复相关如下:
- App-iOS平台 修复 nvue map 组件 moveToLocation 方法不触发回调的Bug 详情
在这个版本说明中只修复了 moveToLocation 方法不触发回调的Bug , 没有修复 平移到指定经纬度的bug,现在我iPhone8 上仍旧是平移到当前位置,我需要的是平移到我指定的经纬度的位置!现在我的HBX版本为2.8.3+ 需要卸载HBX重新安装HBX? 手机上已经卸载重装了HBX基座!
2020-08-04 11:42
-

<template>
<view>
<map id="test_map" ref="map1" style="width: 750rpx; height: 300px;" :show-location="true" :longitude="map.longitude"
:latitude="map.latitude">
</map>
<button @click="dingwei">定位到"北京西站"</button>
<button @click="dingwei2">ref 定位到"北京西站"</button>
</view>
</template>
<script>
export default {
data() {
return {
map: {
longitude: '', //经度
latitude: '', //纬度
}
}
},
onLoad() {
let _this = this;
uni.getLocation({
type: 'gcj02',
success: function(res) {
_this.map.longitude = res.longitude;
_this.map.latitude = res.latitude;
}
});
},
onReady() {
this.mapContext = uni.createMapContext('test_map', this);
},
methods: {
dingwei() {
//官方API uni.createMapContext(mapId,this)
//其中API对应方法之一: moveToLocation(OBJECT) //将地图中心移动到当前定位点,需要配合map组件的show-location使用
//需要实现的目标:定位平移 到指定坐标位置.比如案例中定位到"北京西站"
//实际结果: 在iPhone8中,定位平移 到本人真实的当前位置
this.mapContext.moveToLocation({
//该固定坐标为高德地图拾取,位置:北京西站
latitude: 39.894589,
longitude: 116.32125,
success: function(res) {
console.log("此处无回调!!!本条信息未在控制台打印");
console.log(res);
}
});
},
dingwei2() {
this.$refs.map1.moveToLocation({
//该固定坐标为高德地图拾取,位置:北京西站
latitude: 39.894589,
longitude: 116.32125
},
function(res) {
console.log("此处无回调!!!本条信息未在控制台打印");
console.log(res);
}
);
}
}
}
</script>
<style>
</style>