高德地图 您所在的位置:网站首页 如何删除腾讯地图标注 高德地图

高德地图

2023-08-31 10:01| 来源: 网络整理| 查看: 265

添加标记:

 

1、marker.setMap(map);

2、marker.add([marker]);

 删除标记:

1.marker.setMap(null); 2 map.remove([marker1,marker2]);(前提是map用add添加的标记)

添加标记-多点标记 *{ padding: 0; margin: 0; list-style: none; } #container{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; } #searchNode{ position: absolute; z-index: 9; width: 300px; height: 100px; background: white; text-align: center; padding-top: 20px; } #setCenterNode{ position: absolute; z-index: 9; width: 300px; background: white; top: 100px; } .amap-icon img{ width: 25px; height: 34px; } var map = new AMap.Map('container',{ zoom:10, center:[116.379391,39.861536] }); var marker = new AMap.Marker({ icon:'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', //标记的图标 position:[116.379391,39.861536], //标记的坐标 offset:new AMap.Pixel(-50,-500) //像素的偏差值 }); marker.setMap(map); map.on('click',function(e){ //console.log(e.lnglat); var marker = new AMap.Marker({ icon:'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png', position:[e.lnglat.lng,e.lnglat.lat], offset:new AMap.Pixel(-10,-20) }); //marker.setMap(map); /* setTimeout(function(){ marker.setMap(null); },5000); */ map.add([marker]); setTimeout(function(){ map.remove([marker]); },5000); })

 



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有