Add Tags:
1、marker.setMap(map);
2, marker.add ([flag]);
Delete Tag:
1.marker.setMap (null); 2 map.remove ([MARKER1, MARKER2]); (with the proviso that add labeled map added)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.11&key=9de88a718781910c9a1c81230827d1ce&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script> <title>添加标记-多点标记</title> <style> *{ 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; } </style> </head> <body> <div id="container"></div> <script> var map = new AMap.Map('container',{ Zoom: 10 , Center: [ 116.379391 , 39.861536 ] }); var marker = new new AMap.Marker ({ icon: ' https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker- Default.png ' , // icon labeled position: [ 116.379391 , 39.861536 ], // marker coordinate offset: new new AMap.Pixel (- 50 , - 500 ) // offset value of the pixel }); marker.setMap (Map); map.on ( ' the 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); }) </script> </body> </html>