这次的主要目的是在百度地图中引用自定义的覆盖物,路径是再asset/images/文件夹下,直接引用出错。需要先导入再引用。

在<script></script>代码中增加如下:

 1     import gisGreen from '../assets/images/GIS_Green2.png';
 2     export default {……
 3         methods:{
 4             ……,
 5             handler ({BMap, map}) {
 6               var point = new BMap.Point(120.66, 31.20);
 7               map.centerAndZoom(point, 13);
 8               var myIcon = new BMap.Icon(gisGreen, new BMap.Size(20, 32));
 9               var marker = new BMap.Marker(point, {icon: myIcon}); // 创建标注
10               map.addOverlay(marker); // 将标注添加到地图中
11             },
12         }        
13     }
14     

 

posted on 2019-11-06 15:08  浅悠  阅读(2320)  评论(0编辑  收藏  举报