项目场景:
小程序需要使用地图导航
页面:
<template>
<view class="">
<view class="ditu">
<map style="width:100%;height:100%;"
:latitude="latitude"
:longitude="longitude"
:scale="scale"
:markers="marker"
@markertap="toMap()">
<
@markertap 是点击地图上的标记点时 触发打开地图。
@tap 是点击地图整体的时候 触发打开地图。
-->
</map>
</view>
</view>
</template>
export default {
data() {
return {
latitude: '', //纬度
longitude: '', //经度
marker: [{
id: 0,
latitude: '', //纬度
longitude: '', //经度
// title: '山东某某有限公司', //标注点名
alpha: 1, //透明度
}],
scale: 14, //地图缩放程度
address: ''
}
},
}
大开地图方法:
methods: {
//点击地图上的标记,打开手机内置地图
toMap() {
console.log('点击地图')
uni.openLocation({
latitude: Number(this.latitude), //要去的纬度
longitude: Number(this.longitude), //要去的经度
address: this.address, //要去的具体地址
}) }, }