【vue-baidu-map】绘制折线(带方向箭头)

Vue.js实现BaiduMap的图标与折线展示
该文章展示了如何在Vue.js应用中集成BaiduMap,创建标记图标并绘制折线。通过定义`<baidu-map>`组件,设置地图中心、缩放级别以及添加图标和折线功能。同时,文章提供了自定义组件`new-polyline`来处理路径和图标序列,确保地图元素的动态更新和交互。

 主文件代码

<template>
  <div class="container">
    <baidu-map style="width: 100%;height: 100vh;"
               :center="center" :zoom="zoom" @ready="handler"
               :scroll-wheel-zoom="true" :mapClick="false"
               @moveend="syncCenterAndZoom" @zoomend="syncCenterAndZoom">
      <!-- 图标 -->
      <bm-marker v-for="item in maps" :key="item.id"
                 :position="{lng: item.longitude, lat: item.latitude}"
                 :icon="{url: require('@/assets/images/location.png'), size: {width: 40, height: 40}}"
      >
      </bm-marker>
      <!-- 箭头折线 -->
      <new-polyline
        v-if="points && points.length >= 2 && checkPoints({ points })"
        :path="points"
        :icons="icons"
        stroke-color="#0091ea"
        :stroke-opacity="0.8"
        :stroke-weight="10"
      ></new-polyline>
    </baidu-map>
  </div>
</template>
<script>
import newPolyline from "./new_polyline";

export default {
  components: {
    newPolyline
  },
  data() {
    return {
      center: {
        lng: 0,
        lat: 0
      },
      map: "", // 地图
      maps: [], // 站点信息数组
      nowStationId: '',
      timeId: "", //循环
      zoom: 13,
      co
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值