vue里使用高德地圖h5內(nèi)嵌小程序跳轉(zhuǎn),在小程序是打不開的,需要判斷在小程序內(nèi),調(diào)起小程序地圖組件
h5中的地圖是這樣展示的,在微信小程序是無法跳轉(zhuǎn)的
引入jweixin.js
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
vue里判斷
<a class="more" @click="onmore">到這去</a>
const onmore = () => {
let h5Url = window.location.href
if (window.__wxjs_environment == 'miniprogram') {
// alert("在小程序")
wx.miniProgram.navigateTo({ url: '/pages/webview/webview?longitude=' + longitude.value + '&latitude=' + latitude.value + '&latituname=' + mapname.value + '&address='+address.value+'&url='+h5Url+' ' })
} else {
// alert("不在小程序")
window.location.href = `https://uri.amap.com/marker?position=${jwd1.value}&name=${mapnamedata.value}`;
}
}
在小程序這邊接收傳過來的參數(shù)(需要注意的是:高德地圖坐標(biāo)和騰訊坐標(biāo)是一樣的,只需要經(jīng)緯度反過來即可)文章來源:http://www.zghlxwxcb.cn/news/detail-515024.html
if(options.latitude != '' && options.latitude != undefined ){
let longitude = options.latitude;
let latitude = options.longitude;
let address = options.address;
let name = options.latituname
console.log(options.url)
longitude = parseFloat(longitude);
latitude = parseFloat(latitude);
wx.openLocation({
longitude: latitude,
latitude: longitude,
name:name,
address: address,
scale: 15,
})
}
最后在小程序中呈現(xiàn)是這樣,就完美實(shí)現(xiàn)了文章來源地址http://www.zghlxwxcb.cn/news/detail-515024.html
到了這里,關(guān)于高德地圖H5內(nèi)嵌小程序遇到的跳轉(zhuǎn)地圖問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!