1.点击地图上面的红旗图片后,在地图上面点击动态添加标注

<div
  style=”position:absolute;top:7px; right:450px; z-index:20;cursor:pointer;background:#cccccc;border:1px solid #ffffff;width:60px;height:30px;text-align:center;”>
  <img class=”mypig” imgVal=”1″ src=\’../images/flag.png\’ />
 </div>

 

2.

$(\’.mypig\’).live(
   “click”,
   function(even) {
    window.clickPointer = “tuodong”;
    drawingManager.close();
    var str = $(this).attr(“imgVal”);
    map.addEventListener(“click”, function(e) {
     if (str == 1) {
      var point = new BMap.Point(e.point.lng, e.point.lat);
      var myIcon = new BMap.Icon(“../images/flag.png”,
        new BMap.Size(38, 47));
      var marker = new BMap.Marker(point, {
       icon : myIcon
      }); // 创建标注
      marker.disableMassClear();
      map.addOverlay(marker);
     }
     str = 0;
    });
   });

版权声明:本文为lyming原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/lyming/p/4140194.html