例如在首页点击地图到目的地,显示出导航
然后出现导航页面

首页代码index.vue

<template>
<!-- 地图1 -->
        <view style="margin: 10rpx 0" @click="mapEvent">
          <map
            style="width: 100%; height: 400rpx"
            :latitude="hospitalInfo?.latitude"
            :longitude="hospitalInfo?.longitude"
            :markers="covers"
            @click="mapEvent"
            @markertap="mapEvent"
            catchtap="mapEvent"
          >
          </map>
</template>

<script setup>
import { ref } from 'vue'
// 地图经纬度
const covers = ref([
  {
    id: 1, // 添加唯一标识符
    latitude: '目的地的维度', // 中心纬度
    longitude: '目的地的经度', // 中心经度
    // iconPath: '../../../static/location.png',
    iconPath: '../../static/images/location.png', // 添加图标
    width: 45, // 必须:设置图标的显示宽度(单位:px)
    height: 45, // 必须:设置图标的显示高度(单位:px)
  },
])


// 跳转导航
const mapEvent = () => {
  uni.openLocation({
    latitude: '目的地的维度', // 中心纬度
    longitude: '目的地的经度', // 中心经度
    name: '目的地',
    address: '目的地的地址',
  })
}
</script>

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐