1.首先你需要申請 騰訊地圖 key
2.使用 HBuilder X 編輯器的 小伙伴 們
3.找到uni-app 項目的 manifest.json 文件 如圖
image.png
4.打開 manifest.json 文件 選擇H5配置 如圖
image.png
5.選擇H5配置后 找到定位和地圖 如圖
image.png
6.在你需要使用 導航的頁面 以下 添加點擊事件
注意:只有在真機上測試有效,在電腦上模擬手機是不行的
/* 點擊 導航位置 */
OpenLocation(lat,lng){
console.log(lat,lng)
if(lat && lng){
uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的經緯度
success: function (res) {
console.log(res);
uni.openLocation({
latitude: Number(lat),
longitude:Number(lng),
success: function (res) {
console.log(res);
console.log('success');
}
});
}
});
}else{
this.showToast('暫無位置信息無法導航位置哦');
}
},


