高德地图添加多个标注的

引入高德地图api

 <script type="text/javascript">
  window._AMapSecurityConfig = {
    securityJsCode: "xxxx", //高德地图秘钥
  };
</script>

<script src="https://webapi.amap.com/loader.js"></script>

配置地图

<script type="text/javascript">
 AMapLoader.load({
    key: "xxxx", //申请好的Web端开发者 Key,调用 load 时必填
    version: "2.0", //指定要加载的 JS API 的版本,缺省时默认为 1.4.15
  }).then((AMap) => {
      const map = new AMap.Map("container",{
		  zoom:8, //地图级别
          center: [108.27331,22.78121],  //地图中心
		  });	
			var markers = [  // 标注数组
			   {
				   coordinate:[108.30, 22.75],
				   img:'images/shdz.png',		   
			   },		   
			     {
				   coordinate:[108.881058, 22.875931],
				   img:'images/shdz.png',
			   },
			    {
				   coordinate:[108.8103, 23.21768],
				   img:'images/shdz.png',
			   },
			   {
				   coordinate:[109.22238,23.7521],
				   img:'images/shdz.png',			   
			   }					
			];		
			for (var i = 0; i < markers.length; i++) {
				var marker = new AMap.Marker({
					position: markers[i].coordinate,
				    icon:new AMap.Icon({            
			          image:markers[i].img,
			          size: new AMap.Size(60, 60),  //图标所处区域大小
			          imageSize: new AMap.Size(60,60) //图标大小
		              }),       
		            offset: new AMap.Pixel(-30, -60), 
				    map: map					
				});
			}
       polyline.setMap(map);// 添加到地图
    })
    .catch((e) => {
      console.error(e); //加载错误提示
    });
	
</script>
  <div id="container"></div>

效果图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

功能点分享

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值