老师我想提问
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.4"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/LuShu/1.2/src/LuShu_min.js"></script>
<title>27.1删除标注</title>
</head>
<body>
<div class="wrapper">
<div class="container clearfix">
<div class="clearfix">
<div style="clear: both;">
<div style="float: left; width: 500px; height: 340px; border: 1px solid gray" id="container">
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("container");
var point = new BMap.Point(116.404, 39.950507);
map.centerAndZoom(point, 16);
// var marker = new BMap.Marker(point);
// map.addOverlay(marker);
map.addEventListener("click",function(e){
var point = new BMap.Point(e.point.lng,e.point.lat);
// map.centerAndZoom(point, 15);
var marker = new BMap.Marker(point); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
map.addEventListener("rightclick",function(e){
var point = new BMap.Point(e.point.lng,e.point.lat);
// var marker = new BMap.Marker(point);
map.cleanOverlays(marker);
});
});
// marker.addEventListener("rightclick", function () {
// map.removeOverlay(marker);
// });
// var menu = new BMap.ContextMenu();
// var txtMenuItem = [
// {
// text: "删除标注",
// callback: function () {
// map.removeOverlay(marker);
// }
// }];
// for (var i = 0; i < txtMenuItem.length; i++) {
// menu.addItem(new BMap.MenuItem(txtMenuItem[i].text, txtMenuItem[i].callback, 100));
// }
// map.addContextMenu(menu);
</script>
老师我想做删除marker 能随意添加 还能随意删除怎么写呢?
我是初学者