使用uniapp之-在微信小程序內打開騰訊地圖app或高德地圖app


坑點:

uniapp的button按鈕open-type有launchApp,打開APP的功能,但是場景有使用限制,具體參考官方文檔(https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html)

我的寫法:

<template>
	<view>
		open by map app
	</view>
</template>
<script>
export default {
	onLoad() {
		uni.getLocation({
			success: res => {
				console.log('location success', res)
				uni.openLocation({
					latitude: res.latitude,
					longitude: res.longitude,
					scale: 18
				})
			}
		})
	}
}
</script>
<style lang="scss">
</style>

只要調用該接口(uni.openLocation()),就會自動打開一個新的頁面,點擊右下角綠標可以看到高德地圖,騰訊地圖等。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM