veu中高德怎么定义多个marker?

发布于:2022-10-19 ⋅ 阅读:(418) ⋅ 点赞:(0)

import AMapLoader from '@amap/amap-jsapi-loader'

// 设置安全密钥

window._AMapSecurityConfig = {

  securityJsCode: 'key', //设置高德安全密钥,通过该秘钥获取高德数据

}

这样写只能定义个个图标,想要同时可以展示多个图标,不知道应该怎么写

  initMap() {

      //初始化地图

      AMapLoader.load({

        key: '4e6ba029956ccb2e22f28fb782008a94',

        version: '2.0',

        plugins: ['AMap.Scale', 'AMap.MouseTool'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等

      })

        .then((AMap) => {

          // 初始化地图

          this.map = new AMap.Map('container', {

            viewMode: '3D',

            zoom: 22,

            plugins: [''],

            center: this.firstArr, //[119.980915962, 30.520096745]

            resizeEnable: true,

          })

       

          // 自定义图标

            var IconImg = new AMap.Icon({

              // 图标尺寸

              size: new AMap.Size(80, 40),

              // 图标的取图地址

              image: require('../assets/icon_btk41kc4q9m/Bus.png'),

              // 图标所用图片大小

              imageSize: new AMap.Size(40, 20),

              // imageSize: new AMap.Size(80, 40),

              // 图标取图偏移量

              // imageOffset: new AMap.Pixel(-9, -3)

            })

            this.marker = new AMap.Marker({

              map: this.map,

              // position: this.pereptionInfoList.map(item => [item.longitude,item.latitude])[0],

              position: [119.980915962, 30.520096745],

              // position: new AMap.LngLat(119.980915962, 30.520096745),

              icon: IconImg,

              offset: new AMap.Pixel(-35, -15), //调整图片偏移

              // offset: new AMap.Pixel(-56, -30), //调整图片偏移

              // autoRotation: true, //自动旋转

              // angle: -90 //图片旋转角度

            })

         

        })

        .catch((e) => {

          console.log(e)

        })

    },

本文含有隐藏内容,请 开通VIP 后查看